/* MainForm.cs
 * Author: Richard Broker                                                                                                     *
 * Purpose: Main UI form for Tame Ship Calculator.
 * Note: Holy moly, this class is monstrous.
 *
 *  This file is part of Tame.
 *
 *  Tame is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Tame is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Tame. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Threading;
using System.Text.RegularExpressions;
using System.Diagnostics;
using Tame.ShipStructure;
using Tame.Objects;
using Tame.Objects.Character;
using Tame.Objects.Crew;
using Tame.Objects.Ship;


namespace Tame
{
    public partial class MainForm : Form
    {
        // Set up Pen to draw rectangles
        Pen GreyPen = new Pen(Color.LightGray, 1);

        // Create instances of custom classes for use by the GUI:
        Equipment ShipEquipment = new Equipment();
        Ship playerShip = new Ship();
        Rank rankData = new Rank();
        Guns gunClass = new Guns();
        shipGunControl gunCtrl = new shipGunControl();
        ImagePackHandling imagePackHandler = new ImagePackHandling();
        DrawingFunctions drawingFunctions = new DrawingFunctions();
        GCrew Crew = new GCrew();
        MiscMath myMaths = new MiscMath();        

        // Set coloured brushes for filling rectangles
        SolidBrush hullBrush = new SolidBrush(Color.Blue);
        SolidBrush lightGrayBrush = new SolidBrush(Color.LightGray);
        SolidBrush sizeBrush = new SolidBrush(Color.Red);
        SolidBrush shieldBrush = new SolidBrush(Color.Purple);
        SolidBrush armorBrush = new SolidBrush(Color.Green);
        SolidBrush whiteBrush = new SolidBrush(Color.White);
        SolidBrush orangeBrush = new SolidBrush(Color.Orange);
        SolidBrush greenBrush = new SolidBrush(Color.Green);
        SolidBrush redBrush = new SolidBrush(Color.Red);
        SolidBrush fancyb1 = new SolidBrush(Color.MidnightBlue);
        SolidBrush fancyb2 = new SolidBrush(Color.MediumVioletRed);
        SolidBrush fancyb3 = new SolidBrush(Color.MediumSeaGreen);
        SolidBrush notEnoughSpaceBrush = new SolidBrush(Color.Red);
        SolidBrush usedSpaceBrush = new SolidBrush(Color.Green);
        SolidBrush totalSpaceBrush = new SolidBrush(Color.Blue);

        // Tells program that a non-default imagepack setting is being used.
        bool impackURLmodified = false;
        bool usingXMLimpackPath = false;

       // Allows functions to behave differently when called - for example, not prompting user intervention.
        bool startup = false;
        bool shutdown = false;

        // Not really taken care of - doesn't work properly. #FIXME
        bool unsavedChanges = false;

        // Stops infinite loops with pilot tab radio buttons.
        bool radioButtonFlag = false;

        // Used for graph redraw management.
        bool pieChartDrawn = false;

        // Used in cloaking calculations.
        double inv_fieldrad = 0;

        // CrewViewer Variables:
        // { active (Y/N), leg, name, cost, effect1, effect2, type, level};
        string[,] activeCrew = {
                            {"N","leg","John", "10", "+2MAN", "+4 MAN", "", ""},
                               {"N","leg","John", "10", "+2MAN", "+4 MAN", "", ""},
                               {"N","leg","John", "10", "+2MAN", "+4 MAN", "", ""},
                               {"N","leg","John", "10", "+2MAN", "+4 MAN", "", ""}
                          };
    
        int activeCrewCount = 0;
        int crewViewerIndex = 0;
        int availableCrewSeats = 0;
        string fscVersion = "FSCv4.3";

        // Set regional settings:
        // Get the Culture that you want to use - prevents issues parsing "." and "," with maths due to regional differences. #FIXME just add cultureinfo.currentculture to the damn parse method!
        System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.GetCultureInfo("en-GB");

        string imagePackPath = "c:/pardus/images/";
        //string imagePackPath = "http://herbal-jazz.net/pardus/images/";

        // Tame Directory
        string tameDirectory;
        string shipFile;
        string pilotFile;
        string settingsFile;
        string crewFile;
        string universe = "";

        // Form Panes
        Tame.MainUI.OptionsPane optionsPane = null;
        Tame.MainUI.AboutPane aboutPane = null;
        Tame.MainUI.CrewPane crewPane = null;
        Tame.MainUI.DesignerPane designerPane = null;       

        public MainForm()
        {
            InitializeComponent();
            System.Threading.Thread.CurrentThread.CurrentCulture = ci; // Crash Avoidance when copying to clipboard.
            //***is this sort of code even in the right place?
            //fooInstance = new Instance(foo,ship,);
            //ProfileInstance.addProfileInstance(Instance);
            //this.shipSelectBox.Items.Add(ProfileInstance._ships);
        }

        
        
        // Armor Data Array
        private int[,] ArmorData()
        {
            // Format: {strength, cost, rank}
            int[,] armorData = {
                                   {1,6500,0}, /*0. Titanium */
                                   {2, 56000, 0}, /* 1. Tritanium */
                                   {3, 290000, 0}, /* 2. Zortrium */
                                   {4, 935000, 0}, /* 3. Neutronium */
                                   {5, 2870000,0}, /* 4. Adamantium */
                                   {6, 2990000,39}, /* 5. Ebidium */
                                   {2, 190000,0}, /* 6. Worm-Slime */
                                   {3, 435000,0}, /* 7. Mykoplasmic */
                                   {4,1400000,0}, /* 8. Mutagen */
                                   {5,4305000,0}, /* 9. Genotrope */
                                   {2, 200000,0}, /* 10. Fermion */
                                   {3, 464000, 0}, /* 11. Boson */
                                   {4, 1560000, 0}, /* 12. Positron */
                                   {5, 4856000,0}, /* 13. Anti-Neutrino */
                                   {1,6500,0}, /* 14: Pardus I */
                                   {2,56000,0}, /* 15: Pardus II */
                                   {3, 290000,0}, /* 16: Pardus III */
                                   {4,935000,0}, /* 17: Pardus IV */
                                   {5, 2870000,0}, /* 18: Pardus V */
                                   {6, 2990000,39}, /* 19: Pardus VI */
                               };
            return armorData;
        }

        // Missile Data Array
        private int[,] MissileData()
        {
            // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
            int[,] missileData = {
                                     {45,1,1,4,1000,0}, // ): P80 Sidewinder
                                     {90,1,1,4,2500,0}, // 1: KL760 Homing
                                     {135,2,2,4,6000,0}, // 2: LV111 Intelligent
                                     {255,2,5,4,16000,0}, // 3: NN500 Fleet
                                     {255,3,5,4,32000,0}, // 4: NN 550 Fleet
                                     {315,3,5,4,17500,26}, // 5: MO89 Lord
                                     {60,4,1,3,1500,22}, // 6: G-7 Smartwinder
                                     {150,2,2,3,7000,24}, // 7: A/50 Pogo
                                     {225,3,4,3,18000,25}, // 8: D/70 Havar
                                     {270,4,5,3,62500,28}, // 9: Elite Mk.I
                                     {270,5,6,3,62500,28}, // 10: Elite Mk.II
                                     {1200,6,20,19,1000000,211}, // 11: King Relon
                                     {1800,6,28,19,1500000,212}, // 12: King Kraak
                                     {2300,3,12,15,2500000,214}, // 13: Royal Redeemer
                                 };
            return missileData;
        }

        // Special Equipment Data Array
        private int[,] SpecialData()
        {
            // Format {0: weight, 1: cost, 2: RANK!},
            int[,] specialData = {
                                     {2,3000,0}, // 0: Auto-Refueller
                                     {5,10000,0}, // 1: Escape Pod
                                     {1,1800,0}, // 2: Fuel Scoop
                                     {2,24000,0}, // 3: Bussard Stripminescoop.
                                     {2,20000,0}, // 4: Magnetic Scoop.
                                     {1,30000,0}, // 5: Ambush Teleporter
                                     {5,25000,0}, // 6: Class I Teleporter
                                     {8,60000,0}, // 7: Class II Teleporter
                                     {0,2000,0}, //8: Map Pack I
                                     {0,7000,0}, //9: Map Pack II
                                     {0,15000,0}, // 10: Bouny Link I
                                     {0, 150000,0}, // 11: Bounty Link II
                                     {0, 375000,0}, // 12: Bounty Link III
                                     {0, 860000,313}, // 13: Gyro Stabiliser I
                                     {0, 2400000,314}, // 14: Gyro Stabiliser II

                                     {1,240000,0}, // 15: ECM Jammer
                                     {1,280000,35}, // 16: Strong ECM Jammer
                                     {1,40000,37}, // 17: ECCM Jammer
                                     {2,340000,311}, // 18: Weak Gas Flux
                                     {2,460000,313}, // 19: Weak Energy Flux
                                     {2,980000,313}, // 20: Strong Gas Flux
                                     {2,1400000,314}, // 21: Strong Energy Flux
                                     {1,7000000,314}, // 22: Key of sheppard
                                     {1,32000,50}, // 23: EPS Contraband - any EPS rank, 50.
                                     {2,200000,3844}, // 24: Cloaker - needs Uni-8, TSS-4.
                                     {3,350000,46}, // 25: Improved Cloaker
                                     {1,60000,3642}, // 26: SW-IF Uni-6, TSS-2.
                                     {1,160000,31147}, // 27: DW-IF Uni 11, TSS-7.
                                     {1,260000,410}, // 28: TW-IF TSS 10.
                                     {1,65000,43}, // 29: Damping Field
                                     {1,190000,48}, // 30. Reinforced Damping Field
                                     {1,650000,412}, // 31. Perfected Damping Field
                                     {6,400000,45}, // 32: Light Demat I
                                     {10,500000,48}, // 33: Medium Demat I
                                     {18,600000,411}, // 34: Heavy Demat I
                                     {6,750000,47}, // 35: Light Demat II
                                     {10,950000,410}, // 36: Medium Demat II
                                     {18,1150000,413}, // 37: Heavy Demat II
                                     {1,280000,50}, // 38: EPS Contraband Drone!
                                     {0, 80000, 401} // 39. TSS Bodypart masker
                                };
            return specialData;
        }

        private void shipSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;

            // Remove old ship image:
            shipImageBox.Image = null;

            // Take the piss out of lanner pilots.
            if ((shipSelectBox.Text == "- Lanner") || (shipSelectBox.Text == "- Lanner Mini"))
            {
                gunzlabel.Text = "WTF No Guns?!?";
            }
            else
            {
                gunzlabel.Text = "Select Guns:";
            }

            // Ship specification variables.
            int missileMounts;
            int gunMounts;
            // int hullCapacity;
            int shipSize;
            int shipArmor;
            int shipHull;
            int shipPrice;
            int shipXPRankRequirements;
            int shieldPoints;
            int shipHullCapacity;
            int crewSeats;

            // Array lookup modes:
            int modeMissileMounts = 0;
            int modeGunMounts = 1;
            int modeHullCapacity = 2;
            int modeSize = 3;
            int modeArmor = 4;
            int modeHull = 5;
            //int modeClass = 6;
            int modeShieldPoints = 0;
            int modeXpRankRequirement = 7;
            int modeShipPrice = 8;
            int modeCrewSeats = 9;
            string requiredRankImageURL;
            string requiredRankString;
            string imagePackPath;

            // Get ship data from array:
            shipSize = playerShip.GetShipData(ref modeSize, shipSelectBox.Text);
            shipArmor = playerShip.GetShipData(ref modeArmor, shipSelectBox.Text);
            shipHull = playerShip.GetShipData(ref modeHull, shipSelectBox.Text);
            gunMounts = playerShip.GetShipData(ref modeGunMounts, shipSelectBox.Text);
            missileMounts = playerShip.GetShipData(ref modeMissileMounts, shipSelectBox.Text);
            shipPrice = playerShip.GetShipData(ref modeShipPrice, shipSelectBox.Text);
            shipXPRankRequirements = playerShip.GetShipData(ref modeXpRankRequirement, shipSelectBox.Text);
            shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            shieldPoints = ShipEquipment.GetShieldData(ref modeShieldPoints, shieldSelectComboBox.Text);

            // NEW 13/11/2010
            gunCtrl.setListMax(gunMounts); // Set maxmium number of guns in gunCtrl;
            EnableorDisableGunBoxes();

            // Add numerical values to complement info-bars:
            shipSizeNumericalLabel.Text = shipSize.ToString();
            hullPointsNumericalLabel.Text = shipHull.ToString();
            armorPointsNumericalLabel.Text = shipArmor.ToString();
            shieldPointsNumericalLabel.Text = shieldPoints.ToString();


            // Add Data to info-labels under ship selection:
            shipPriceLabel.Text = shipPrice.ToString("N0");

            // Change what label says if ships have a rank or XP requirement "0" adds an exception for the sabre's 0 xp requirement.
            // Reset rank image tooltip:
            toolTip1.SetToolTip(this.requiredRankForShipPictureBox, "");
            requiredRankForShipPictureBox.ImageLocation = null;
            if ((shipXPRankRequirements > 644) || (shipXPRankRequirements == 0))
            {
                rankOrXPLabel.Text = "Required XP:";
                requiredRankLabel.Text = shipXPRankRequirements.ToString("N0");
                requiredRankForShipPictureBox.Image = null;
            }
            if ((shipXPRankRequirements < 644) && (shipXPRankRequirements != 0))
            {
                imagePackPath = GetImagePackPath();
                rankOrXPLabel.Text = "Required Rank:";
                requiredRankLabel.Text = rankData.ParseRankIDToString( shipXPRankRequirements);
                requiredRankString = rankData.ParseRankIDToString( shipXPRankRequirements);
                requiredRankImageURL = ConvertRankStringsToImagePaths(ref requiredRankString);
                requiredRankImageURL = Path.Combine(imagePackPath, requiredRankImageURL);
                requiredRankForShipPictureBox.ImageLocation = requiredRankImageURL;
                toolTip1.SetToolTip(this.requiredRankForShipPictureBox, rankData.ParseRankIDToString( shipXPRankRequirements));
            }

            // Add ship image
            try
            {
                shipImageBox.ImageLocation = ConstructShipImagePaths();
            }
            catch (UriFormatException)
            {
                MessageBox.Show("Error creating ship image file path. Contact Pigeon", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            // Draws standard info-bars
            ScreenRefresh();

            // Get Missile Mounts - Enable appropriate number of boxes.
            EnableorDisableMissileBoxes(ref missileMounts);

            // Enable Crew Seats.
            crewSeats = playerShip.GetShipData(ref modeCrewSeats, shipSelectBox.Text);
            availableCrewSeats = crewSeats;
           
            updateCrewButtons();
           

            // change effective armor value
            int modeStrength = 0;
            int armorStrength = 0;
            armorStrength = GetArmorData(ref modeStrength);
            effectiveArmorLabel.Text = ((shipArmor * armorStrength).ToString() + " (Effective).");
            hullFortComboBox_SelectedIndexChanged(sender, e);


            // Check for rank conflicts
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void driveSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            // When new drive is selected
            int modeSpeed = 0;
            int modeFuelConsumption = 1;
            int modeTankSize = 2;
            int modeWeight = 3;
            int modeEvasion = 4;
            int modeCost = 5;
            int modeRankRequirements = 6;

            int driveSpeed;
            int driveFuelConsumption;
            int driveTankSize;
            int driveWeight;
            double driveEvasion;
            int driveCost;
            int driveRankRequirement;
            string imagePackPath;
            string driveRankImagePath;
            string driveRankRequirementString;

            driveSpeed = ShipEquipment.GetDriveData(ref modeSpeed, driveSelectBox.Text);
            driveFuelConsumption = ShipEquipment.GetDriveData(ref modeFuelConsumption, driveSelectBox.Text);
            driveTankSize = ShipEquipment.GetDriveData(ref modeTankSize, driveSelectBox.Text);
            driveWeight = ShipEquipment.GetDriveData(ref modeWeight, driveSelectBox.Text);
            driveEvasion = ShipEquipment.GetDriveData(ref modeEvasion, driveSelectBox.Text);
            driveCost = ShipEquipment.GetDriveData(ref modeCost, driveSelectBox.Text);
            driveRankRequirement = ShipEquipment.GetDriveData(ref modeRankRequirements, driveSelectBox.Text);

            driveSpeedLabel2.Text = driveSpeed.ToString();
            driveFuelConsumptionLabel2.Text = driveFuelConsumption.ToString();
            driveTankSizeLabel2.Text = driveTankSize.ToString();
            driveWeightLabel2.Text = driveWeight.ToString();


            // Divide evasion value by 100 because formatting as "%" multiplies by 100. Need to use type double, else precision lost.
            driveEvasion = driveEvasion / 100.0;
            driveEvasionBonusLabel2.Text = driveEvasion.ToString("P0");
            driveCostLabel2.Text = driveCost.ToString("N0");

            imagePackPath = GetImagePackPath();
            driveRankRequirementString = rankData.ParseRankIDToString( driveRankRequirement);
            driveRankImagePath = ConvertRankStringsToImagePaths(ref driveRankRequirementString);
            driveRankImageBox2.ImageLocation = Path.Combine(imagePackPath, driveRankImagePath);

            // Add equipment image
            string driveImageURL = "";
            driveImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(driveSelectBox.Text);
            driveImageURL = Path.Combine(imagePackPath, driveImageURL);
            selectedDrivePictureBox2.ImageLocation = driveImageURL;

            // Modify XP Icons:
            if ((driveSelectBox.Text != "Antimatter Drive") && (driveSelectBox.Text != "Hyper Drive") && (driveSelectBox.Text != "Interphased Drive"))
            {
                toolTip1.SetToolTip(this.driveRankImageBox2, rankData.ParseRankIDToString( driveRankRequirement));
                driveRankImageBox2.Image = null;
            }
            switch (driveSelectBox.Text)
            {
                case "Antimatter Drive":
                    driveRankImageBox2.ImageLocation = null;
                    driveRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.driveRankImageBox2, "420XP Required");
                    break;

                case "Hyper Drive":
                    driveRankImageBox2.ImageLocation = null;
                    driveRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.driveRankImageBox2, "1700XP Required");
                    break;


                case "Interphased Drive":
                    driveRankImageBox2.ImageLocation = null;
                    driveRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.driveRankImageBox2, "3500XP Required");
                    break;

            }

            // Check for rank conflicts
            CheckForRankRequirementConflicts();

            // Redraw used space.
            int modeHullCapacity = 2;
            int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
            shipHullCapacity = shipHullCapacity / 2;

            determineMovementCost();

            updateSummaryPage();

        }

        /// <summary>
        /// updates the drive speed indicators on the "drives" tab
        /// </summary>
        private void determineMovementCost()
        {
            int modeSpeed = 0;
            int gasFluxCapBonus = 0;
            int energyFluxCapBonus = 0;
            int driveSpeed = ShipEquipment.GetDriveData(ref modeSpeed, driveSelectBox.Text);
            double bonus = 1;
            int level = 0;
            int k, i;
            bool Secondary = false;
            try
            {
                for (k = 0; k < 5; k++)
                {
                    if (activeCrew[k, 0] == "Y")
                    {
                        if (activeCrew[k, 1] == "leg")
                        {
                            // First Effect
                            for (i = 0; i < 2; i++)
                            {
                                if (i == 1)
                                {
                                    Secondary = true;
                                }
                                switch (Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex))
                                {
                                   // Crew member is a pathfinder! Primary or secondary.
                                    case 5:
                                        bonus = (bonus + Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary));
                                        break;                                    
                                }
                            }
                        }
                    }
                }
                        
            }
            catch (Exception) { }
            //END CREW
            //reset text colours
                movementAsteroidLabel.ForeColor = Color.Black;
                movementEMLabel.ForeColor = Color.Black;
                movementEnergyLabel.ForeColor = Color.Black;
                movementNebLabel.ForeColor = Color.Black;
                movementSpaceLabel.ForeColor = Color.Black;
                movementViralLabel.ForeColor = Color.Black;
            
            if (fluxCapacitorSelectBox.SelectedIndex == 1)
            {
                gasFluxCapBonus = 1;
            }
            if (fluxCapacitorSelectBox.SelectedIndex == 3)
            {
                gasFluxCapBonus = 2;
            }
            if (fluxCapacitorSelectBox.SelectedIndex == 2)
            {
                energyFluxCapBonus = 1;
            }
            if (fluxCapacitorSelectBox.SelectedIndex == 4)
            {
                energyFluxCapBonus = 2;
            }
            if (energyFluxCapBonus > 0)
            {
                movementEnergyLabel.ForeColor = Color.Green;
            }
            if (gasFluxCapBonus > 0)
            {
                movementNebLabel.ForeColor = Color.Green;
            }           
            if (bonus != 1)
            {
                movementAsteroidLabel.ForeColor = Color.Green;
                movementEMLabel.ForeColor = Color.Green;
                movementEnergyLabel.ForeColor = Color.Green;
                movementNebLabel.ForeColor = Color.Green;
                movementSpaceLabel.ForeColor = Color.Green;
                movementViralLabel.ForeColor = Color.Green;
            }            
            // mvspeed = baseCost - drivespeed
            movementSpaceLabel.Text = Math.Round((11 - driveSpeed) * bonus).ToString();
            movementNebLabel.Text = Math.Round(((16 - driveSpeed) - gasFluxCapBonus) * bonus).ToString();
            movementViralLabel.Text = Math.Round((18 - driveSpeed) * bonus).ToString();
            movementEnergyLabel.Text = Math.Round(((20 - driveSpeed) - energyFluxCapBonus) * bonus).ToString();
            movementAsteroidLabel.Text = Math.Round((25 - driveSpeed) * bonus).ToString();
            movementEMLabel.Text = Math.Round((36 - driveSpeed) * bonus).ToString();

        }

        private void shieldSelectComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;

            int modePoints = 0;
            int modeRechargeRate = 1;
            int modeWeight = 2;
            int modeCost = 3;
            int modeRankRequirements = 4;

            int shieldPoints;
            int shieldRechargeRate;
            int shieldWeight;
            int shieldCost;
            int shieldRankRequirement;

            string imagePackPath;
            string shieldRankImagePath;
            string shieldRankRequirementString;

            string shieldImageURL = "";

            shieldPoints = ShipEquipment.GetShieldData(ref modePoints, shieldSelectComboBox.Text);
            shieldRechargeRate = ShipEquipment.GetShieldData(ref modeRechargeRate, shieldSelectComboBox.Text);
            shieldWeight = ShipEquipment.GetShieldData(ref modeWeight, shieldSelectComboBox.Text);
            shieldCost = ShipEquipment.GetShieldData(ref modeCost, shieldSelectComboBox.Text);
            shieldRankRequirement = ShipEquipment.GetShieldData(ref modeRankRequirements, shieldSelectComboBox.Text);

            shieldPointsLabel.Text = shieldPoints.ToString();
            shieldChargeRateLabel.Text = shieldRechargeRate.ToString();
            shieldWeightLabel.Text = shieldWeight.ToString();
            shieldCostLabel.Text = shieldCost.ToString();

            imagePackPath = GetImagePackPath();
            shieldRankRequirementString = rankData.ParseRankIDToString( shieldRankRequirement);
            shieldRankImagePath = ConvertRankStringsToImagePaths(ref shieldRankRequirementString);
            shieldRankRequirementImageBox.ImageLocation = Path.Combine(imagePackPath, shieldRankImagePath);

            // Change tooltip + rank
            if ((shieldSelectComboBox.Text != "Standard") && (shieldSelectComboBox.Text != "Medium") && (shieldSelectComboBox.Text != "Large"))
            {
                toolTip1.SetToolTip(this.shieldRankRequirementImageBox, rankData.ParseRankIDToString( shieldRankRequirement));
                shieldRankRequirementImageBox.Image = null;
            }

            // Add equipment image
            shieldImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(shieldSelectComboBox.Text);
            shieldImageURL = Path.Combine(imagePackPath, shieldImageURL);
            shieldImageBox.ImageLocation = shieldImageURL;

            // Check for rank conflicts
            CheckForRankRequirementConflicts();

            // Redraw used space.
            int modeHullCapacity = 2;
            int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
            shipHullCapacity = shipHullCapacity / 2;

            if (shieldPoints > 0)
            {
                shieldPointsNumericalLabel.Text = shieldPoints.ToString();
            }
            else
            {
                shieldPointsNumericalLabel.Text = null;
            }

            shieldPoweringComboBox_SelectedIndexChanged(sender, e);

            switch (shieldSelectComboBox.Text)
            {
                case "Standard":
                    shieldRankRequirementImageBox.ImageLocation = null;
                    shieldRankRequirementImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.shieldRankRequirementImageBox, "900XP Required");
                    break;

                case "Medium":
                    shieldRankRequirementImageBox.ImageLocation = null;
                    shieldRankRequirementImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.shieldRankRequirementImageBox, "2700XP Required");
                    break;

                case "Large":
                    shieldRankRequirementImageBox.ImageLocation = null;
                    shieldRankRequirementImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.shieldRankRequirementImageBox, "6900XP Required");
                    break;
            }
            //Update Summary Page:
            updateSummaryPage();

            // Update Shield info-bar
            ScreenRefresh();
        }

        private int GetArmorData(ref int mode)
        {
            int armorReturnData;
            int[,] temparmorData = ArmorData();

            if ((armorComboBox.Text == "Titanium (x1)") || (armorComboBox.Text == "") || (armorComboBox.Text == "Pardus I") || (armorComboBox.Text == "Electro-Magnetic:") || (armorComboBox.Text == "Organic:") || (armorComboBox.Text == "Conventional"))
            {
                toolTip1.SetToolTip(this.armorRankImageBox, "Rank Required for Armor");
                armorRankImageBox.Image = null;
            }
            //FIXME changing the images and tooltips here is bad! 
            switch (armorComboBox.Text)
            {
                case "":
                case " ":
                case ":: None ::":
                case "Conventional:":
                case "Organic:":
                case "Electro-Magnetic:":
                case "Pardus:":
                    armorReturnData = 0;
                    return armorReturnData;

                case "Titanium (x1)":
                    armorReturnData = temparmorData[0, mode];
                    return armorReturnData;

                case "Tritanium (x2)":
                    armorReturnData = temparmorData[1, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "60XP Required");
                    return armorReturnData;

                case "Zortrium (x3)":
                    armorReturnData = temparmorData[2, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "2400XP Required");
                    return armorReturnData;

                case "Neutronium (x4)":
                    armorReturnData = temparmorData[3, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "8850XP Required");
                    return armorReturnData;

                case "Adamantium (x5)":
                    armorReturnData = temparmorData[4, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "28200XP Required");
                    return armorReturnData;

                case "Ebidium (x6)":
                    armorReturnData = temparmorData[5, mode];
                    return armorReturnData;

                case "Worm-Slime (x2)":
                    armorReturnData = temparmorData[6, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "1400XP Required");
                    return armorReturnData;

                case "Mykoplasmic (x3)":
                    armorReturnData = temparmorData[7, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "3850XP Required");
                    return armorReturnData;

                case "Mutagen (x4)":
                    armorReturnData = temparmorData[8, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "13500XP Required");
                    return armorReturnData;

                case "Genotrope (x5)":
                    armorReturnData = temparmorData[9, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "42550XP Required");
                    return armorReturnData;

                case "Fermion (x2)":
                    armorReturnData = temparmorData[10, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "1500XP Required");
                    return armorReturnData;

                case "Boson (x3)":
                    armorReturnData = temparmorData[11, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "4140XP Required");
                    return armorReturnData;

                case "Positron (x4)":
                    armorReturnData = temparmorData[12, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "15100XP Required");
                    return armorReturnData;

                case "Anti-Neutrino (x5)":
                    armorReturnData = temparmorData[13, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "48060XP Required");
                    return armorReturnData;

                case "Pardus I":
                    armorReturnData = temparmorData[14, mode];
                    return armorReturnData;

                case "Pardus II":
                    armorReturnData = temparmorData[15, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "60XP Required");
                    return armorReturnData;

                case "Pardus III":
                    armorReturnData = temparmorData[16, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "2400XP Required");
                    return armorReturnData;

                case "Pardus IV":
                    armorReturnData = temparmorData[17, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "8850XP Required");
                    return armorReturnData;

                case "Pardus V":
                    armorReturnData = temparmorData[18, mode];
                    armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.armorRankImageBox, "28200XP Required");
                    return armorReturnData;

                case "Pardus VI":
                    armorReturnData = temparmorData[19, mode];
                    return armorReturnData;

            }
            return 0;
        }

        // #FIXME Terrible implementation.
        private int GetMissileData(ref int mode, ref string comboBoxSel)
        {
            var comboBox = "";
            int missileReturnData;
            int[,] tempMissileData = MissileData();

            // See which  box we're on about.
            if (comboBoxSel == missileLoadoutComboBox1.Name)
            {
                comboBox = missileLoadoutComboBox1.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox2.Name)
            {
                comboBox = missileLoadoutComboBox2.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox3.Name)
            {
                comboBox = missileLoadoutComboBox3.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox4.Name)
            {
                comboBox = missileLoadoutComboBox4.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox5.Name)
            {
                comboBox = missileLoadoutComboBox5.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox6.Name)
            {
                comboBox = missileLoadoutComboBox6.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox7.Name)
            {
                comboBox = missileLoadoutComboBox7.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox8.Name)
            {
                comboBox = missileLoadoutComboBox8.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox9.Name)
            {
                comboBox = missileLoadoutComboBox9.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox10.Name)
            {
                comboBox = missileLoadoutComboBox10.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox11.Name)
            {
                comboBox = missileLoadoutComboBox11.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox12.Name)
            {
                comboBox = missileLoadoutComboBox12.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox13.Name)
            {
                comboBox = missileLoadoutComboBox13.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox14.Name)
            {
                comboBox = missileLoadoutComboBox14.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox15.Name)
            {
                comboBox = missileLoadoutComboBox15.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox16.Name)
            {
                comboBox = missileLoadoutComboBox16.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox17.Name)
            {
                comboBox = missileLoadoutComboBox17.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox18.Name)
            {
                comboBox = missileLoadoutComboBox18.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox19.Name)
            {
                comboBox = missileLoadoutComboBox19.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox20.Name)
            {
                comboBox = missileLoadoutComboBox20.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox21.Name)
            {
                comboBox = missileLoadoutComboBox21.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox22.Name)
            {
                comboBox = missileLoadoutComboBox22.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox23.Name)
            {
                comboBox = missileLoadoutComboBox23.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox24.Name)
            {
                comboBox = missileLoadoutComboBox24.Text;
            }
            if (comboBoxSel == missileLoadoutComboBox25.Name)
            {
                comboBox = missileLoadoutComboBox25.Text;
            }

            switch (comboBox)
            {

                case ":: None ::":
                case "":
                    missileReturnData = 0;
                    return missileReturnData;

                case "P80 Sidewinder":
                    missileReturnData = tempMissileData[0, mode];
                    return missileReturnData;

                case "KL760 Homing":
                    missileReturnData = tempMissileData[1, mode];
                    return missileReturnData;

                case "LV111 Intelligent":
                    missileReturnData = tempMissileData[2, mode];
                    return missileReturnData;

                case "NN500 Fleet":
                    missileReturnData = tempMissileData[3, mode];
                    return missileReturnData;

                case "NN550 Fleet":
                    missileReturnData = tempMissileData[4, mode];
                    return missileReturnData;

                case "Imperial MO89 Lord":
                    missileReturnData = tempMissileData[5, mode];
                    return missileReturnData;

                case "Imperial G-7 Smartwinder":
                    missileReturnData = tempMissileData[6, mode];
                    return missileReturnData;

                case "Imperial A/50 Pogo":
                    missileReturnData = tempMissileData[7, mode];
                    return missileReturnData;

                case "Imperial D/70 Havar":
                    missileReturnData = tempMissileData[8, mode];
                    return missileReturnData;

                case "Imperial Elite Mk.I":
                    missileReturnData = tempMissileData[9, mode];
                    return missileReturnData;

                case "Imperial Elite Mk.II":
                    missileReturnData = tempMissileData[10, mode];
                    return missileReturnData;

                case "King Relon":
                    missileReturnData = tempMissileData[11, mode];
                    return missileReturnData;

                case "King Kraak":
                    missileReturnData = tempMissileData[12, mode];
                    return missileReturnData;

                case "Royal Redeemer":
                    missileReturnData = tempMissileData[13, mode];
                    return missileReturnData;
            }
            return 0;
        }

        private void customIPCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            // Show/Hide Non-default imagepack options as reqiested by user input
            if (customIPCheckBox.Checked == true)
            {
                customIPTextBox.Visible = true;
                imagePackComboBox.Visible = false;
                imagepackNotesLabel.Text = "Type in your new imagepack path, for example:" + Environment.NewLine + "c:/pardus/images/";
            }

            // Show/Hide Non-default imagepack options as reqiested by user input
            else
            {
                imagePackComboBox.Visible = true;
                customIPTextBox.Visible = false;
                imagepackNotesLabel.Text = "Standard Offline Path is: c:/pardus/images/ " + Environment.NewLine + "HQ Offline Path is: c:/pardus/images_standardhq/";
            }
        }

        private void customIPTextBox_MouseClick(object sender, MouseEventArgs e)
        {
            // Delete text initially in the custom text box, so user can insert appropriate data.
            if (customIPTextBox.Text == "Custom Imagepack Path")
            {
#if MONO // Fix for MONO bug: https://bugzilla.novell.com/show_bug.cgi?id=621475
                customIPTextBox.SelectionStart = 0;
#endif
                customIPTextBox.Text = "";
            }
            impackURLmodified = true;
        }

        private void imagePackComboBox_MouseClick(object sender, MouseEventArgs e)
        {
            // Let program know if a non-default IP setting is in use.
            impackURLmodified = true;
        }

        private string ConstructShipImagePaths()
        {
            string shipImagePath = Environment.SpecialFolder.Personal.ToString();

            // Used to get rid of the "- " in front of each of the ship names - makes it easier to manage the picture box display.
            int startIndex = 0;
            int count = 2;

            // Used in the string replace function, takes out spaces - puts in underscores.
            string oldChar = " ";
            string newChar = "_";

            // Convert strings from the drop down list to a corresponding image name in an imagepack. e.g. "- Wasp" >> "wasp_big.png" 
            shipImagePath = String.Format("{0} big.png", shipSelectBox.Text);
            shipImagePath = shipImagePath.Replace(oldChar, newChar);
            shipImagePath = shipImagePath.Remove(startIndex, count);
            shipImagePath = shipImagePath.ToLower();

            //Add exceptions for badly labelled images in the imagepack
            if (shipImagePath == "el_padre_big.png")
            {
                shipImagePath = "elpadre_big.png";
            }
            if (shipImagePath == "junker_iv_big.png")
            {
                shipImagePath = "junkeriv_big.png";
            }
            // Displays no image on non-ship entries in the drop down list such as "TSS Ships".
            if ((shipImagePath == "_select_ship_::_big.png") || (shipImagePath == "ig.png") || (shipImagePath == "utral_ships_big.png") || (shipImagePath == "deration_ships_big.png") || (shipImagePath == "pire_ships_big.png") || (shipImagePath == "ion_ships_big.png") || (shipImagePath == "s_ships_big.png"))
            {
                shipImageBox.Visible = false;
                shipImagePath = null;
            }
            else
            {
                shipImageBox.Visible = true;

                imagePackPath = GetImagePackPath();

                // Concatenate all calculated image path information.
                shipImagePath = Path.Combine(imagePackPath, Path.Combine("big", shipImagePath));
            }
            return shipImagePath;


        }  // End of ConstructShipImagePaths()

        private void imagePackComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            // Resets image to match user's new selection by grabbing a new image path.
            usingXMLimpackPath = false;
            imagePackPath = GetImagePackPath();
            shipImageBox.ImageLocation = ConstructShipImagePaths();
            setupNoGenImages();
            raceSelectBox_SelectedIndexChanged(sender, e);
        }

        private void customIPTextBox_TextChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            usingXMLimpackPath = false;
            imagePackPath = GetImagePackPath();
            setupNoGenImages();
            raceSelectBox_SelectedIndexChanged(sender, e);
        }

        private string GetImagePackPath()
        {

            if (usingXMLimpackPath == true)
            {
                return imagePackPath;
            }
            else
            {
                // If non-preset imagepack path is being used.
                if (customIPCheckBox.Checked == true)
                {
                    // Get custom path from input box.
                    return customIPTextBox.Text;
                }
                // If presets are being used - get appropriate image path.
                else
                {
                    if (imagePackComboBox.SelectedIndex == 0)
                    {
#if !MONO // C:/pardus/images for Windows
                        return "c:/pardus/images/";
#endif
#if MONO
                        return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Path.Combine("pardus", "images"));							
#endif
                    }
                    if (imagePackComboBox.SelectedIndex == 1)
                    {
#if !MONO // C:/pardus/images for Windows
                        return "c:/pardus/images_standard/";
#endif
#if MONO
                        return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Path.Combine("pardus", "images_standard"));	
#endif
                    }
                    if (imagePackComboBox.SelectedIndex == 2)
                    {
#if !MONO // C:/pardus/images for Windows
                        return "c:/pardus/images_standardhq/";
#endif
#if MONO
                        return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Path.Combine("pardus", "images_standardhq"));	
#endif
                    }
                    if (imagePackComboBox.SelectedIndex == 3)
                    {
                        return "http://static.pardus.at/images/";
                    }
                    if (imagePackComboBox.SelectedIndex == 4)
                    {
                        return "http://static.pardus.at/img/std/";
                    }
                    if (imagePackComboBox.SelectedIndex == 5)
                    {
                        return "http://herbal-jazz.net/pardus/images/";
                    }
                    if (imagePackComboBox.SelectedIndex == 6)
                    {
                        return "http://herbal-jazz.net/pardus/images_standard/";
                    }
                }
            }
            
            return imagePackPath;


        }

        #region Drawing Info-bars.

        // Standard Info-bars:
        private void DrawStandardShipSizeBar(ref int shipSize)
        {
            int x = (250 - shipSize);

            Graphics drawShipSizeBar = shipSizePanel.CreateGraphics();
            drawShipSizeBar.FillRectangle(whiteBrush, shipSize, 0, x, 10);
            drawShipSizeBar.FillRectangle(sizeBrush, 0, 0, shipSize, 10);
        }

        private void DrawStandardShipArmorBar(ref int shipArmor)
        {
            int x = (250 - shipArmor);

            Graphics drawShipArmorBar = shipArmorPanel.CreateGraphics();
            drawShipArmorBar.FillRectangle(whiteBrush, shipArmor, 0, x, 10);
            drawShipArmorBar.FillRectangle(armorBrush, 0, 0, shipArmor, 10);
        }

        private void DrawStandardShipHullBar(ref int shipHull)
        {
            int x = (250 - shipHull);

            Graphics drawShipHullBar = shipHullPanel.CreateGraphics();
            drawShipHullBar.FillRectangle(whiteBrush, shipHull, 0, x, 10);
            drawShipHullBar.FillRectangle(hullBrush, 0, 0, shipHull, 10);
        }

        private void DrawStandardShipShieldBar(ref int shieldPoints)
        {
            int x = (250 - shieldPoints);

            Graphics drawShipShieldBar = shipShieldPanel.CreateGraphics();
            drawShipShieldBar.FillRectangle(whiteBrush, shieldPoints, 0, x, 10);
            drawShipShieldBar.FillRectangle(shieldBrush, 0, 0, shieldPoints, 10);
        }

        // Bars to left of ship image - free space total and used:
        private void DrawStandardShipFreeSpaceBar(ref int shipHullCapacity)
        {
            int y = (165 - shipHullCapacity);

            // Draw Bar:
            Graphics drawShipFreeSpaceBar = panel14.CreateGraphics();
            drawShipFreeSpaceBar.FillRectangle(whiteBrush, 0, shipHullCapacity, 10, y);
            drawShipFreeSpaceBar.FillRectangle(totalSpaceBrush, 0, 0, 10, shipHullCapacity);

            // Add label to bar.
            int modeHullCapacity = 2;
            shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            totalShipSpaceLabel.Text = String.Format("{0}T", shipHullCapacity);
        }

        private void DrawStandardShipUsedSpaceBar(ref int shipHullCapacity)
        {
            int modeWeight = 3;
            int modeShieldWeight = 2;
            int gunSpace = freeSpaceRequiredForGuns();
            int driveSpace = ShipEquipment.GetDriveData(ref modeWeight, driveSelectBox.Text);
            int shieldSpace = ShipEquipment.GetShieldData(ref modeShieldWeight, shieldSelectComboBox.Text);
            int missileSpace = aggregateMissileWeight();
            int specialSpace = calculateTotalSpecialWeight();

            var brush = usedSpaceBrush;
            string x = "";
            int y;

            int totalSpace = (((gunSpace) + (driveSpace) + (shieldSpace) + (missileSpace) + (specialSpace)) / 2); // Placeholder for when more equipment is added.

            if (totalSpace > 165)
            {
                totalSpace = 165;
                x = ">";
            }

            if ((totalSpace * 2) < shipHullCapacity)
            {
                brush = usedSpaceBrush;
            }
            if ((totalSpace * 2) >= shipHullCapacity)
            {
                brush = notEnoughSpaceBrush;
            }

            y = (165 - totalSpace);

            Graphics drawShipUsedSpaceBar = panel15.CreateGraphics();
            drawShipUsedSpaceBar.FillRectangle(whiteBrush, 0, totalSpace, 10, y);
            drawShipUsedSpaceBar.FillRectangle(brush, 0, 0, 10, totalSpace);

            // Recalculate total space without halvings, so that it can be displayed without rounding errors
            totalSpace = ((gunSpace) + (driveSpace) + (shieldSpace) + (missileSpace) + (specialSpace));
            shipSpaceUsedLabel.Text = String.Format("{0}{1}T", x, totalSpace);

            freeSpaceRemainingLabelMAIN.Text = (shipHullCapacity - totalSpace).ToString() + "T";
            if ((shipHullCapacity - totalSpace) > 5)
            {
                freeSpaceRemainingLabelMAIN.ForeColor = Color.Green;
            }
            if (((shipHullCapacity - totalSpace) <= 5) && ((shipHullCapacity - totalSpace > 0)))
            {
                freeSpaceRemainingLabelMAIN.ForeColor = Color.DarkOrange;
            }
            if ((shipHullCapacity - totalSpace) <= 0)
            {
                freeSpaceRemainingLabelMAIN.ForeColor = Color.Red;
            }
        } // End of free space total and used.

        // Fancy Pie Charts
        private void DrawArmorPieCharts()
        {
            // To format as %, value is multiplied by 100.
            float efficiency = 0;
            float degreesVsConv;
            float degreesVsEM;
            float degreesVsOrg;
            float degreesVsPardus;
            float pieSize = 49;
            float boxSize = 52;

            Graphics drawArmorPieChartvsConv = armorPieChartPanel1.CreateGraphics();
            if (disablePieChartAACheckBox.Checked != true)
            {
                drawArmorPieChartvsConv.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }
            Graphics drawArmorPieChartvsORG = armorPieChartPanel2.CreateGraphics();
            if (disablePieChartAACheckBox.Checked != true)
            {
                drawArmorPieChartvsORG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }

            Graphics drawArmorPieChartvsEM = armorPieChartPanel3.CreateGraphics();
            if (disablePieChartAACheckBox.Checked != true)
            {
                drawArmorPieChartvsEM.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }
            Graphics drawArmorPieChartvsPardus = armorPieChartPanel4.CreateGraphics();
            if (disablePieChartAACheckBox.Checked != true)
            {
                drawArmorPieChartvsPardus.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }
            if ((armorComboBox.Text == "Titanium (x1)") || (armorComboBox.Text == "Tritanium (x2)") || (armorComboBox.Text == "Zortrium (x3)") || (armorComboBox.Text == "Neutronium (x4)") || (armorComboBox.Text == "Adamantium (x5)") || (armorComboBox.Text == "Ebidium (x6)"))
            {
                efficiency = 100;
                convEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsConv = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsConv.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsConv.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsConv);

                efficiency = 100;
                orgEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsOrg = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsORG.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsORG.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsOrg);

                efficiency = 110;
                emEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsEM = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsEM.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsEM.FillPie(redBrush, 0, 0, pieSize, pieSize, 0, degreesVsEM);

                efficiency = 100;
                pardusEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsPardus = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsPardus.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsPardus.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsPardus);
            }

            if ((armorComboBox.Text == "Organic:") || (armorComboBox.Text == "Conventional:") || (armorComboBox.Text == "Electro-Magnetic") || (armorComboBox.Text == "Pardus:") || (armorComboBox.Text == "") || (armorComboBox.Text == " "))
            {
                convEfficiencyLabel.Text = "0%";
                drawArmorPieChartvsConv.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);

                orgEfficiencyLabel.Text = "0%";
                drawArmorPieChartvsORG.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);

                emEfficiencyLabel.Text = "0%";
                drawArmorPieChartvsEM.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);

                pardusEfficiencyLabel.Text = "0%";
                drawArmorPieChartvsPardus.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
            }
            if ((armorComboBox.Text == "Worm-Slime (x2)") || (armorComboBox.Text == "Mykoplasmic (x3)") || (armorComboBox.Text == "Mutagen (x4)") || (armorComboBox.Text == "Genotrope (x5)"))
            {
                efficiency = 60;
                convEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsConv = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsConv.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsConv.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsConv);

                efficiency = 50;
                orgEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsOrg = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsORG.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsORG.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsOrg);

                efficiency = 125;
                emEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsEM = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsEM.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsEM.FillPie(redBrush, 0, 0, pieSize, pieSize, 0, degreesVsEM);

                efficiency = 100;
                pardusEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsPardus = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsPardus.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsPardus.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsPardus);
            }

            if ((armorComboBox.Text == "Fermion (x2)") || (armorComboBox.Text == "Boson (x3)") || (armorComboBox.Text == "Positron (x4)") || (armorComboBox.Text == "Anti-Neutrino (x5)"))
            {
                efficiency = 60;
                convEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsConv = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsConv.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsConv.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsConv);

                efficiency = 100;
                orgEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsOrg = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsORG.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsORG.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsOrg);

                efficiency = 50;
                emEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsEM = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsEM.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsEM.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsEM);

                efficiency = 125;
                pardusEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsPardus = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsPardus.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsPardus.FillPie(redBrush, 0, 0, pieSize, pieSize, 0, degreesVsPardus);
            }
            if ((armorComboBox.Text == "Pardus I") || (armorComboBox.Text == "Pardus II") || (armorComboBox.Text == "Pardus III") || (armorComboBox.Text == "Pardus IV") || (armorComboBox.Text == "Pardus V") || (armorComboBox.Text == "Pardus VI"))
            {
                efficiency = 45;
                convEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsConv = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsConv.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsConv.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsConv);

                efficiency = 55;
                orgEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsOrg = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsORG.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsORG.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsOrg);

                efficiency = 75;
                emEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsEM = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsEM.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsEM.FillPie(greenBrush, 0, 0, pieSize, pieSize, 0, degreesVsEM);

                efficiency = 100;
                pardusEfficiencyLabel.Text = efficiency.ToString("N0") + "%";
                degreesVsPardus = drawingFunctions.ConvertEfficiencyToDegrees(ref efficiency);
                drawArmorPieChartvsPardus.FillRectangle(lightGrayBrush, 0, 0, boxSize, boxSize);
                drawArmorPieChartvsPardus.FillPie(orangeBrush, 0, 0, pieSize, pieSize, 0, degreesVsPardus);
            }

        }
        #endregion

        #region GunSelectionBoxes

        // Copy-links.
        private void copyLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // Fearsome Ship Calc - style links to copy gun data from box to box.
            ComboBox[] gunCombos = { gunLoadoutComboBox1, gunLoadoutComboBox2, gunLoadoutComboBox3, gunLoadoutComboBox4, gunLoadoutComboBox5 };

            for (int i = 1; i < 5; i++)
            {
                if (gunCombos[i].Enabled == true)
                {
                    gunCombos[i].Text = gunCombos[0].Text;
                }
            }
            
        }

        private void copyLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ComboBox[] gunCombos = { gunLoadoutComboBox2, gunLoadoutComboBox3, gunLoadoutComboBox4, gunLoadoutComboBox5 };

            for (int i = 1; i < 4; i++)
            {
                if (gunCombos[i].Enabled == true)
                {
                    gunCombos[i].Text = gunCombos[0].Text;
                }
            }
        }

        private void CopyLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ComboBox[] gunCombos = { gunLoadoutComboBox3, gunLoadoutComboBox4, gunLoadoutComboBox5 };

            for (int i = 1; i < 3; i++)
            {
                if (gunCombos[i].Enabled == true)
                {
                    gunCombos[i].Text = gunCombos[0].Text;
                }
            }
        } 

        private void CopyLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ComboBox[] gunCombos = { gunLoadoutComboBox4, gunLoadoutComboBox5 };

            for (int i = 1; i < 2; i++)
            {
                if (gunCombos[i].Enabled == true)
                {
                    gunCombos[i].Text = gunCombos[0].Text;
                }
            }
        }// End of Copy-links.

        // Function Selects a value from the array containing Gun data. Mode allows you to select which data to pull from the table.
        // Note - there is one "lookup table" such as this for each of the 5 gun boxes.
        
        private int GetGunData2(ref int mode)
        {
            int gunDatareturn;
            int[,] gunDataTemp = gunClass.GunData;
            int modeRank = 4;
            int gunRank = gunClass.GetGunData(ref modeRank, gunLoadoutComboBox2.Text);

          
            switch (gunLoadoutComboBox2.Text)
            {
                case ":: None ::":
                case ":: Normal Guns::":
                case ":: Empire Guns ::":
                case "":
                case " ":
                case ":: Organic ::":
                case ":: Electro-Magnetic ::":
                case ":: Pardus ::":
                    gunDatareturn = gunDataTemp[0, mode];
                    return gunDatareturn;

                case "10MW Mining Laser":
                    gunDatareturn = gunDataTemp[1, mode];
                    return gunDatareturn;

                case "30MW Mining Laser":
                    gunDatareturn = gunDataTemp[2, mode];
                    return gunDatareturn;

                case "1MW Impulse Laser":
                    gunDatareturn = gunDataTemp[3, mode];
                    return gunDatareturn;

                case "5MW Impulse Laser":
                    gunDatareturn = gunDataTemp[4, mode];
                    return gunDatareturn;

                case "1MW Particle Laser":
                    gunDatareturn = gunDataTemp[5, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "360XP Required");
                    return gunDatareturn;

                case "4MW Particle Laser":
                    gunDatareturn = gunDataTemp[6, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "1600XP Required");
                    return gunDatareturn;

                case "4MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[7, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "4600XP Required");
                    return gunDatareturn;

                case "20MW Particle Laser":
                    gunDatareturn = gunDataTemp[8, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "5000XP Required");
                    return gunDatareturn;

                case "20MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[9, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "8750XP Required");
                    return gunDatareturn;

                case "100MW Particle Laser":
                    gunDatareturn = gunDataTemp[10, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "9300XP Required");
                    return gunDatareturn;

                case "100MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[11, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "19500XP Required");
                    return gunDatareturn;

                case "4MW Gatling Laser":
                    gunDatareturn = gunDataTemp[12, mode];
                    return gunDatareturn;

                case "4MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[13, mode];
                    return gunDatareturn;

                case "6MW Gatling Laser":
                    gunDatareturn = gunDataTemp[14, mode];
                    return gunDatareturn;

                case "6MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[15, mode];
                    return gunDatareturn;

                case "10MW Gatling Laser":
                    gunDatareturn = gunDataTemp[16, mode];
                    return gunDatareturn;

                case "10MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[17, mode];
                    return gunDatareturn;

                case "20MW Gatling Laser":
                    gunDatareturn = gunDataTemp[18, mode];
                    return gunDatareturn;

                case "20MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[19, mode];
                    return gunDatareturn;

                case "35MW Plasma":
                    gunDatareturn = gunDataTemp[20, mode];
                    return gunDatareturn;

                case "40MW Plasma":
                    gunDatareturn = gunDataTemp[21, mode];
                    return gunDatareturn;

                case "60MW Plasma":
                    gunDatareturn = gunDataTemp[22, mode];
                    return gunDatareturn;

                case "140MW Particle Laser":
                    gunDatareturn = gunDataTemp[23, mode];
                    return gunDatareturn;

                case "140MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[24, mode];
                    return gunDatareturn;

                case "Exoplasm Launcher":
                    gunDatareturn = gunDataTemp[25, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "5300XP Required");
                    return gunDatareturn;

                case "Endoplasm Launcher":
                    gunDatareturn = gunDataTemp[26, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "3500XP Required");
                    return gunDatareturn;

                case "Bio-Spore Array":
                    gunDatareturn = gunDataTemp[27, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "8000XP Required");
                    return gunDatareturn;

                case "Viral Glands":
                    gunDatareturn = gunDataTemp[28, mode];
                    // Add image, add tooltip.
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "16000XP Required");
                    return gunDatareturn;

                case "80MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[29, mode];
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "6000XP Required");
                    return gunDatareturn;

                case "120MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[30, mode];
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "9000XP Required");
                    return gunDatareturn;

                case "Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[31, mode];
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "19300XP Required");
                    return gunDatareturn;

                case "Very Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[32, mode];
                    gunRankImageBox2.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox2, "25500XP Required");
                    return gunDatareturn;

                case "Lucidi Enforcer I":
                    gunDatareturn = gunDataTemp[33, mode];
                    return gunDatareturn;

                case "Lucidi Enforcer II":
                    gunDatareturn = gunDataTemp[34, mode];
                    return gunDatareturn;

                case "Lucidi Conqueror":
                    gunDatareturn = gunDataTemp[35, mode];
                    return gunDatareturn;

                case "Lucidi Plasma Thrower":
                    gunDatareturn = gunDataTemp[36, mode];
                    return gunDatareturn;
            }
            return 0;
        }

        private int GetGunData3(ref int mode)
        {
            int gunDatareturn;
            int[,] gunDataTemp = gunClass.GunData;
            int modeRank = 4;
            int gunRank = gunClass.GetGunData(ref modeRank, gunLoadoutComboBox3.Text);


            // Delete image, add tooltip.
            if ((gunLoadoutComboBox3.Text != "1MW Particle Laser") && (gunLoadoutComboBox3.Text != "4MW Particle Laser") && (gunLoadoutComboBox3.Text != "4MW LW Particle Laser") && (gunLoadoutComboBox3.Text != "20MW Particle Laser") && (gunLoadoutComboBox3.Text != "20MW LW Particle Laser") && (gunLoadoutComboBox3.Text != "100MW Particle Laser") && (gunLoadoutComboBox3.Text != "100MW LW Particle Laser") && (gunLoadoutComboBox3.Text != "Endoplasm Launcher") && (gunLoadoutComboBox3.Text != "Exoplasm Launcher") && (gunLoadoutComboBox3.Text != "Bio Spore Array") && (gunLoadoutComboBox3.Text != "Viral Glands") && (gunLoadoutComboBox3.Text != "80MT Magnetic Defractor") && (gunLoadoutComboBox3.Text != "120MT Magnetic Defractor") && (gunLoadoutComboBox3.Text != "Large Pulse Cannon") && (gunLoadoutComboBox3.Text != "Very Large Pulse Cannon"))
            {
                toolTip1.SetToolTip(this.gunRankImageBox3, rankData.ParseRankIDToString( gunRank));
                gunRankImageBox3.Image = null;
            }



            switch (gunLoadoutComboBox3.Text)
            {
                case ":: None ::":
                case ":: Normal Guns::":
                case ":: Empire Guns ::":
                case "":
                case " ":
                case ":: Organic ::":
                case ":: Electro-Magnetic ::":
                case ":: Pardus ::":
                    gunDatareturn = gunDataTemp[0, mode];
                    return gunDatareturn;

                case "10MW Mining Laser":
                    gunDatareturn = gunDataTemp[1, mode];
                    return gunDatareturn;

                case "30MW Mining Laser":
                    gunDatareturn = gunDataTemp[2, mode];
                    return gunDatareturn;

                case "1MW Impulse Laser":
                    gunDatareturn = gunDataTemp[3, mode];
                    return gunDatareturn;

                case "5MW Impulse Laser":
                    gunDatareturn = gunDataTemp[4, mode];
                    return gunDatareturn;

                case "1MW Particle Laser":
                    gunDatareturn = gunDataTemp[5, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "360XP Required");
                    return gunDatareturn;

                case "4MW Particle Laser":
                    gunDatareturn = gunDataTemp[6, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "1600XP Required");
                    return gunDatareturn;

                case "4MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[7, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "4600XP Required");
                    return gunDatareturn;

                case "20MW Particle Laser":
                    gunDatareturn = gunDataTemp[8, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "5000XP Required");
                    return gunDatareturn;

                case "20MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[9, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "8750XP Required");
                    return gunDatareturn;

                case "100MW Particle Laser":
                    gunDatareturn = gunDataTemp[10, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "9300XP Required");
                    return gunDatareturn;

                case "100MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[11, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "19500XP Required");
                    return gunDatareturn;

                case "4MW Gatling Laser":
                    gunDatareturn = gunDataTemp[12, mode];
                    return gunDatareturn;

                case "4MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[13, mode];
                    return gunDatareturn;

                case "6MW Gatling Laser":
                    gunDatareturn = gunDataTemp[14, mode];
                    return gunDatareturn;

                case "6MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[15, mode];
                    return gunDatareturn;

                case "10MW Gatling Laser":
                    gunDatareturn = gunDataTemp[16, mode];
                    return gunDatareturn;

                case "10MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[17, mode];
                    return gunDatareturn;

                case "20MW Gatling Laser":
                    gunDatareturn = gunDataTemp[18, mode];
                    return gunDatareturn;

                case "20MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[19, mode];
                    return gunDatareturn;

                case "35MW Plasma":
                    gunDatareturn = gunDataTemp[20, mode];
                    return gunDatareturn;

                case "40MW Plasma":
                    gunDatareturn = gunDataTemp[21, mode];
                    return gunDatareturn;

                case "60MW Plasma":
                    gunDatareturn = gunDataTemp[22, mode];
                    return gunDatareturn;

                case "140MW Particle Laser":
                    gunDatareturn = gunDataTemp[23, mode];
                    return gunDatareturn;

                case "140MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[24, mode];
                    return gunDatareturn;

                case "Exoplasm Launcher":
                    gunDatareturn = gunDataTemp[25, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "5300XP Required");
                    return gunDatareturn;

                case "Endoplasm Launcher":
                    gunDatareturn = gunDataTemp[26, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "3500XP Required");
                    return gunDatareturn;

                case "Bio-Spore Array":
                    gunDatareturn = gunDataTemp[27, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "8000XP Required");
                    return gunDatareturn;

                case "Viral Glands":
                    gunDatareturn = gunDataTemp[28, mode];
                    // Add image, add tooltip.
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "16000XP Required");
                    return gunDatareturn;

                case "80MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[29, mode];
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "6000XP Required");
                    return gunDatareturn;

                case "120MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[30, mode];
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "9000XP Required");
                    return gunDatareturn;

                case "Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[31, mode];
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "19300XP Required");
                    return gunDatareturn;

                case "Very Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[32, mode];
                    gunRankImageBox3.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox3, "25500XP Required");
                    return gunDatareturn;

                case "Lucidi Enforcer I":
                    gunDatareturn = gunDataTemp[33, mode];
                    return gunDatareturn;

                case "Lucidi Enforcer II":
                    gunDatareturn = gunDataTemp[34, mode];
                    return gunDatareturn;

                case "Lucidi Conqueror":
                    gunDatareturn = gunDataTemp[35, mode];
                    return gunDatareturn;

                case "Lucidi Plasma Thrower":
                    gunDatareturn = gunDataTemp[36, mode];
                    return gunDatareturn;
            }
            return 0;
        }

        private int GetGunData4(ref int mode)
        {
            int gunDatareturn;
            int[,] gunDataTemp = gunClass.GunData;
            int modeRank = 4;
            int gunRank = gunClass.GetGunData(ref modeRank, gunLoadoutComboBox4.Text);

            // Delete image, add tooltip.
            if ((gunLoadoutComboBox4.Text != "1MW Particle Laser") && (gunLoadoutComboBox4.Text != "4MW Particle Laser") && (gunLoadoutComboBox4.Text != "4MW LW Particle Laser") && (gunLoadoutComboBox4.Text != "20MW Particle Laser") && (gunLoadoutComboBox4.Text != "20MW LW Particle Laser") && (gunLoadoutComboBox4.Text != "100MW Particle Laser") && (gunLoadoutComboBox4.Text != "100MW LW Particle Laser") && (gunLoadoutComboBox4.Text != "Endoplasm Launcher") && (gunLoadoutComboBox4.Text != "Exoplasm Launcher") && (gunLoadoutComboBox4.Text != "Bio Spore Array") && (gunLoadoutComboBox4.Text != "Viral Glands") && (gunLoadoutComboBox4.Text != "80MT Magnetic Defractor") && (gunLoadoutComboBox4.Text != "120MT Magnetic Defractor") && (gunLoadoutComboBox4.Text != "Large Pulse Cannon") && (gunLoadoutComboBox4.Text != "Very Large Pulse Cannon"))
            {
                toolTip1.SetToolTip(this.gunRankImageBox4, rankData.ParseRankIDToString( gunRank));
                gunRankImageBox4.Image = null;
            }
            switch (gunLoadoutComboBox4.Text)
            {
                case ":: None ::":
                case ":: Normal Guns::":
                case ":: Empire Guns ::":
                case "":
                case " ":
                case ":: Organic ::":
                case ":: Electro-Magnetic ::":
                case ":: Pardus ::":
                    gunDatareturn = gunDataTemp[0, mode];
                    return gunDatareturn;

                case "10MW Mining Laser":
                    gunDatareturn = gunDataTemp[1, mode];
                    return gunDatareturn;

                case "30MW Mining Laser":
                    gunDatareturn = gunDataTemp[2, mode];
                    return gunDatareturn;

                case "1MW Impulse Laser":
                    gunDatareturn = gunDataTemp[3, mode];
                    return gunDatareturn;

                case "5MW Impulse Laser":
                    gunDatareturn = gunDataTemp[4, mode];
                    return gunDatareturn;

                case "1MW Particle Laser":
                    gunDatareturn = gunDataTemp[5, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "360XP Required");
                    return gunDatareturn;

                case "4MW Particle Laser":
                    gunDatareturn = gunDataTemp[6, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "1600XP Required");
                    return gunDatareturn;

                case "4MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[7, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "4600XP Required");
                    return gunDatareturn;

                case "20MW Particle Laser":
                    gunDatareturn = gunDataTemp[8, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "5000XP Required");
                    return gunDatareturn;

                case "20MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[9, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "8750XP Required");
                    return gunDatareturn;

                case "100MW Particle Laser":
                    gunDatareturn = gunDataTemp[10, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "9300XP Required");
                    return gunDatareturn;

                case "100MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[11, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "19500XP Required");
                    return gunDatareturn;

                case "4MW Gatling Laser":
                    gunDatareturn = gunDataTemp[12, mode];
                    return gunDatareturn;

                case "4MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[13, mode];
                    return gunDatareturn;

                case "6MW Gatling Laser":
                    gunDatareturn = gunDataTemp[14, mode];
                    return gunDatareturn;

                case "6MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[15, mode];
                    return gunDatareturn;

                case "10MW Gatling Laser":
                    gunDatareturn = gunDataTemp[16, mode];
                    return gunDatareturn;

                case "10MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[17, mode];
                    return gunDatareturn;

                case "20MW Gatling Laser":
                    gunDatareturn = gunDataTemp[18, mode];
                    return gunDatareturn;

                case "20MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[19, mode];
                    return gunDatareturn;

                case "35MW Plasma":
                    gunDatareturn = gunDataTemp[20, mode];
                    return gunDatareturn;

                case "40MW Plasma":
                    gunDatareturn = gunDataTemp[21, mode];
                    return gunDatareturn;

                case "60MW Plasma":
                    gunDatareturn = gunDataTemp[22, mode];
                    return gunDatareturn;

                case "140MW Particle Laser":
                    gunDatareturn = gunDataTemp[23, mode];
                    return gunDatareturn;

                case "140MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[24, mode];
                    return gunDatareturn;

                case "Exoplasm Launcher":
                    gunDatareturn = gunDataTemp[25, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "5300XP Required");
                    return gunDatareturn;

                case "Endoplasm Launcher":
                    gunDatareturn = gunDataTemp[26, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "3500XP Required");
                    return gunDatareturn;

                case "Bio-Spore Array":
                    gunDatareturn = gunDataTemp[27, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "8000XP Required");
                    return gunDatareturn;

                case "Viral Glands":
                    gunDatareturn = gunDataTemp[28, mode];
                    // Add image, add tooltip.
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "16000XP Required");
                    return gunDatareturn;

                case "80MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[29, mode];
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "6000XP Required");
                    return gunDatareturn;

                case "120MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[30, mode];
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "9000XP Required");
                    return gunDatareturn;

                case "Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[31, mode];
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "19300XP Required");
                    return gunDatareturn;

                case "Very Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[32, mode];
                    gunRankImageBox4.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox4, "25500XP Required");
                    return gunDatareturn;

                case "Lucidi Enforcer I":
                    gunDatareturn = gunDataTemp[33, mode];
                    return gunDatareturn;

                case "Lucidi Enforcer II":
                    gunDatareturn = gunDataTemp[34, mode];
                    return gunDatareturn;

                case "Lucidi Conqueror":
                    gunDatareturn = gunDataTemp[35, mode];
                    return gunDatareturn;

                case "Lucidi Plasma Thrower":
                    gunDatareturn = gunDataTemp[36, mode];
                    return gunDatareturn;
            }
            return 0;
        }

        private int GetGunData5(ref int mode)
        {
            int gunDatareturn;
            int[,] gunDataTemp = gunClass.GunData;
            int modeRank = 4;
            int gunRank = gunClass.GetGunData(ref modeRank, gunLoadoutComboBox5.Text);

            // Delete image, add tooltip.
            if ((gunLoadoutComboBox5.Text != "1MW Particle Laser") && (gunLoadoutComboBox5.Text != "4MW Particle Laser") && (gunLoadoutComboBox5.Text != "4MW LW Particle Laser") && (gunLoadoutComboBox5.Text != "20MW Particle Laser") && (gunLoadoutComboBox5.Text != "20MW LW Particle Laser") && (gunLoadoutComboBox5.Text != "100MW Particle Laser") && (gunLoadoutComboBox5.Text != "100MW LW Particle Laser") && (gunLoadoutComboBox5.Text != "Endoplasm Launcher") && (gunLoadoutComboBox5.Text != "Exoplasm Launcher") && (gunLoadoutComboBox5.Text != "Bio Spore Array") && (gunLoadoutComboBox5.Text != "Viral Glands") && (gunLoadoutComboBox5.Text != "80MT Magnetic Defractor") && (gunLoadoutComboBox5.Text != "120MT Magnetic Defractor") && (gunLoadoutComboBox5.Text != "Large Pulse Cannon") && (gunLoadoutComboBox5.Text != "Very Large Pulse Cannon"))
            {
                toolTip1.SetToolTip(this.gunRankImageBox5, rankData.ParseRankIDToString( gunRank));
                gunRankImageBox5.Image = null;
            }

            switch (gunLoadoutComboBox5.Text)
            {
                case ":: None ::":
                case ":: Normal Guns::":
                case ":: Empire Guns ::":
                case "":
                case " ":
                case ":: Organic ::":
                case ":: Electro-Magnetic ::":
                case ":: Pardus ::":
                    gunDatareturn = gunDataTemp[0, mode];
                    return gunDatareturn;

                case "10MW Mining Laser":
                    gunDatareturn = gunDataTemp[1, mode];
                    return gunDatareturn;

                case "30MW Mining Laser":
                    gunDatareturn = gunDataTemp[2, mode];
                    return gunDatareturn;

                case "1MW Impulse Laser":
                    gunDatareturn = gunDataTemp[3, mode];
                    return gunDatareturn;

                case "5MW Impulse Laser":
                    gunDatareturn = gunDataTemp[4, mode];
                    return gunDatareturn;

                case "1MW Particle Laser":
                    gunDatareturn = gunDataTemp[5, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "360XP Required");
                    return gunDatareturn;

                case "4MW Particle Laser":
                    gunDatareturn = gunDataTemp[6, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "1600XP Required");
                    return gunDatareturn;

                case "4MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[7, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "4600XP Required");
                    return gunDatareturn;

                case "20MW Particle Laser":
                    gunDatareturn = gunDataTemp[8, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "5000XP Required");
                    return gunDatareturn;

                case "20MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[9, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "8750XP Required");
                    return gunDatareturn;

                case "100MW Particle Laser":
                    gunDatareturn = gunDataTemp[10, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "9300XP Required");
                    return gunDatareturn;

                case "100MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[11, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "19500XP Required");
                    return gunDatareturn;

                case "4MW Gatling Laser":
                    gunDatareturn = gunDataTemp[12, mode];
                    return gunDatareturn;

                case "4MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[13, mode];
                    return gunDatareturn;

                case "6MW Gatling Laser":
                    gunDatareturn = gunDataTemp[14, mode];
                    return gunDatareturn;

                case "6MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[15, mode];
                    return gunDatareturn;

                case "10MW Gatling Laser":
                    gunDatareturn = gunDataTemp[16, mode];
                    return gunDatareturn;

                case "10MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[17, mode];
                    return gunDatareturn;

                case "20MW Gatling Laser":
                    gunDatareturn = gunDataTemp[18, mode];
                    return gunDatareturn;

                case "20MW LW Gatling Laser":
                    gunDatareturn = gunDataTemp[19, mode];
                    return gunDatareturn;

                case "35MW Plasma":
                    gunDatareturn = gunDataTemp[20, mode];
                    return gunDatareturn;

                case "40MW Plasma":
                    gunDatareturn = gunDataTemp[21, mode];
                    return gunDatareturn;

                case "60MW Plasma":
                    gunDatareturn = gunDataTemp[22, mode];
                    return gunDatareturn;

                case "140MW Particle Laser":
                    gunDatareturn = gunDataTemp[23, mode];
                    return gunDatareturn;

                case "140MW LW Particle Laser":
                    gunDatareturn = gunDataTemp[24, mode];
                    return gunDatareturn;

                case "Exoplasm Launcher":
                    gunDatareturn = gunDataTemp[25, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "5300XP Required");
                    return gunDatareturn;

                case "Endoplasm Launcher":
                    gunDatareturn = gunDataTemp[26, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "3500XP Required");
                    return gunDatareturn;

                case "Bio-Spore Array":
                    gunDatareturn = gunDataTemp[27, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "8000XP Required");
                    return gunDatareturn;

                case "Viral Glands":
                    gunDatareturn = gunDataTemp[28, mode];
                    // Add image, add tooltip.
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "16000XP Required");
                    return gunDatareturn;

                case "80MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[29, mode];
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "6000XP Required");
                    return gunDatareturn;

                case "120MT Magnetic Defractor":
                    gunDatareturn = gunDataTemp[30, mode];
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "9000XP Required");
                    return gunDatareturn;

                case "Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[31, mode];
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "19300XP Required");
                    return gunDatareturn;

                case "Very Large Pulse Cannon":
                    gunDatareturn = gunDataTemp[32, mode];
                    gunRankImageBox5.Image = Tame.Properties.Resources.xp_icon;
                    toolTip1.SetToolTip(this.gunRankImageBox5, "25500XP Required");
                    return gunDatareturn;

                case "Lucidi Enforcer I":
                    gunDatareturn = gunDataTemp[33, mode];
                    return gunDatareturn;

                case "Lucidi Enforcer II":
                    gunDatareturn = gunDataTemp[34, mode];
                    return gunDatareturn;

                case "Lucidi Conqueror":
                    gunDatareturn = gunDataTemp[35, mode];
                    return gunDatareturn;

                case "Lucidi Plasma Thrower":
                    gunDatareturn = gunDataTemp[36, mode];
                    return gunDatareturn;
            }
            return 0;
        }

        private void updateGun(int start, int end)
        {          
            PictureBox[] equipmentImages = { selectedGunPictureBox1, selectedGunPictureBox2, selectedGunPictureBox3, selectedGunPictureBox4, selectedGunPictureBox5 };
            PictureBox[] gunRankImages = { gunRankImageBox1, gunRankImageBox2, gunRankImageBox3, gunRankImageBox4, gunRankImageBox5 };
            Label[] damageLabels = { gunDamageLabel1, gunDamageLabel2, gunDamageLabel3, gunDamageLabel4, gunDamageLabel5 };
            Label[] fireRateLabels = { gunFireRateLabel1, gunFireRateLabel2, gunFireRateLabel3, gunFireRateLabel4, gunFireRateLabel5 };
            Label[] weightLabels = { gunWeightLabel1, gunWeightLabel2, gunWeightLabel3, gunWeightLabel4, gunWeightLabel5 };
            Label[] costLabels = { gunCostLabel1, gunCostLabel2, gunCostLabel3, gunCostLabel4, gunCostLabel5 };
            Label[] emCostLabels = { gunEMCostLabel1, gunEMCostLabel2, gunEMCostLabel3, gunEMCostLabel4, gunEMCostLabel5 };
            Label[] totalDamageLabels = { totalGunDamageLabel1, totalGunDamageLabel2, totalGunDamageLabel3, totalGunDamageLabel4, totalGunDamageLabel5};

            ComboBox weapSpec = null;            

            float damage = 0;
            int fireRate = 0;
            int xpRequirement = 0;

            for (int i = start; i < end; i++)
            {
                equipmentImages[i].Image = null; equipmentImages[i].ImageLocation = null;
                gunRankImages[i].Image = null; gunRankImages[i].ImageLocation = null;
                xpRequirement = gunCtrl.getGunXPRequirement(i);

                if (xpRequirement > 0)
                {
                    toolTip1.SetToolTip(gunRankImages[i], "XP Required " + xpRequirement.ToString("N0"));
                    gunRankImages[i].Image = Tame.Properties.Resources.xp_icon;                 
                }
                else
                {
                    Rank r = new Rank();
                    gunRankImages[i].ImageLocation = imagePackPath + gunCtrl.getGunRankPath(i);
                    toolTip1.SetToolTip(gunRankImages[i], (r.ParseRankIDToString(gunCtrl.getRankValue(i))));
                }
                equipmentImages[i].ImageLocation = imagePackPath + gunCtrl.getGunImagePath(i);
                
                
                

                weightLabels[i].Text = gunCtrl.getGunWeight(i).ToString("N0");
                costLabels[i].Text = gunCtrl.getGunCost(i).ToString("N0");

                damage = gunCtrl.getGunDamage(i);
                fireRate = gunCtrl.getGunFireRate(i);

                switch (gunCtrl.getGunType(i))
                {
                    case 0: // Conv
                        weapSpec = cWeapSpecLevelComboBox;
                        break;
                    case 1: // Org
                        weapSpec = orgWeapSpecComboBox;
                        break;
                    case 2: // EM
                        weapSpec = emWeapSpecComboBox;
                        break;
                }
                // Apply Weap Spec
                if (weapSpec != null)
                {
                    for (int k = 0; k < 5; k++)
                    {
                        if (weapSpec.SelectedIndex == k)
                        {
                            damage = (damage / 100) * (100 + (k * 5));
                            damage = (float)Math.Round(damage, 0);
                        }
                    }
                }

                if (damage > (gunCtrl.getGunDamage(i) + 0.5))
                {
                    damageLabels[i].ForeColor = Color.Green;
                    totalDamageLabels[i].ForeColor = Color.Green;
                }
                else
                {
                    damageLabels[i].ForeColor = Color.Black;
                    totalDamageLabels[i].ForeColor = Color.Black;
                }

                fireRateLabels[i].Text = fireRate.ToString("N0");
                damageLabels[i].Text = damage.ToString("N0");
                totalDamageLabels[i].Text = (damage * fireRate).ToString("N0");

                if (gunCtrl.isPardusWeapon(i) == true)
                {
                    emCostLabels[i].Visible = true;
                    emCostLabels[i].Text = gunCtrl.getGunExoticCost(i).ToString("N0");
                }
                else
                {
                    emCostLabels[i].Visible = false;
                }
            }

            // Redraw used space.
            int modeHullCapacity = 2;
            int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
            shipHullCapacity = shipHullCapacity / 2;
        }

        // Ask for new data from lookup on user request & update displayed data
        private void gunLoadoutComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {            
            
                unsavedChanges = true;
                gunCtrl.setGun(gunLoadoutComboBox1.SelectedIndex, 0);                
                updateGun(0, 1);

                aggregateGunDamage();
                aggregateGunCost();
                //pardusGunECCost();
                freeSpaceRequiredForGuns();

                // Check for rank conflicts
                CheckForRankRequirementConflicts();
                //Update Summary Page:
                updateSummaryPage();
            

        }

        private void gunLoadoutComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            gunCtrl.setGun(gunLoadoutComboBox2.SelectedIndex, 1);
            updateGun(1, 2);

            aggregateGunDamage();
            aggregateGunCost();
            pardusGunECCost();
            freeSpaceRequiredForGuns();

            // Check for rank conflicts
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void gunLoadoutComboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            gunCtrl.setGun(gunLoadoutComboBox3.SelectedIndex, 2);
            updateGun(2, 3);

            aggregateGunDamage();
            aggregateGunCost();
            pardusGunECCost();
            freeSpaceRequiredForGuns();

            // Check for rank conflicts
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void gunLoadoutComboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            gunCtrl.setGun(gunLoadoutComboBox4.SelectedIndex, 3);
            updateGun(3, 4);

            aggregateGunDamage();
            aggregateGunCost();
            pardusGunECCost();
            freeSpaceRequiredForGuns();

            // Check for rank conflicts
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void gunLoadoutComboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            gunCtrl.setGun(gunLoadoutComboBox5.SelectedIndex, 4);
            updateGun(4, 5);

            aggregateGunDamage();
            aggregateGunCost();
            pardusGunECCost();
            freeSpaceRequiredForGuns();

            // Check for rank conflicts
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void UpdateAllGuns()
        {
            updateGun(0, 5);     
        }

        private void ClearGun(ref int gun)
        {
            if (gun == 1)
            {
                gunLoadoutComboBox1.Text = "";
            }

            if (gun == 2)
            {
                gunLoadoutComboBox2.Text = "";
            }

            if (gun == 3)
            {
                gunLoadoutComboBox3.Text = "";
            }

            if (gun == 4)
            {
                gunLoadoutComboBox4.Text = "";
            }

            if (gun == 5)
            {
                gunLoadoutComboBox5.Text = "";
            }


            // Redraw used space.
            int modeHullCapacity = 2;
            int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
            shipHullCapacity = shipHullCapacity / 2;
        }

        private void EnableorDisableGunBoxes()
        {
            if (gunCtrl.getListMax() == 0)
            {
                gunLoadoutComboBox1.Enabled = false;                
                gunLoadoutComboBox2.Enabled = false;
                gunLoadoutComboBox3.Enabled = false;
                gunLoadoutComboBox4.Enabled = false;
                gunLoadoutComboBox5.Enabled = false;
                gunLoadoutComboBox1.SelectedIndex = 0;
                gunLoadoutComboBox2.SelectedIndex = 0;
                gunLoadoutComboBox3.SelectedIndex = 0;
                gunLoadoutComboBox4.SelectedIndex = 0;
                gunLoadoutComboBox5.SelectedIndex = 0;
            }
            if (gunCtrl.getListMax() == 1)
            {
                gunLoadoutComboBox1.Enabled = true;
                gunLoadoutComboBox2.Enabled = false;
                gunLoadoutComboBox3.Enabled = false;
                gunLoadoutComboBox4.Enabled = false;
                gunLoadoutComboBox5.Enabled = false;
                gunLoadoutComboBox2.SelectedIndex = 0;
                gunLoadoutComboBox3.SelectedIndex = 0;
                gunLoadoutComboBox4.SelectedIndex = 0;
                gunLoadoutComboBox5.SelectedIndex = 0;
            }
            if (gunCtrl.getListMax() == 2)
            {
                gunLoadoutComboBox1.Enabled = true;
                gunLoadoutComboBox2.Enabled = true;
                gunLoadoutComboBox3.Enabled = false;
                gunLoadoutComboBox4.Enabled = false;
                gunLoadoutComboBox5.Enabled = false;
                gunLoadoutComboBox3.SelectedIndex = 0;
                gunLoadoutComboBox4.SelectedIndex = 0;
                gunLoadoutComboBox5.SelectedIndex = 0;
            }
            if (gunCtrl.getListMax() == 3)
            {
                gunLoadoutComboBox1.Enabled = true;
                gunLoadoutComboBox2.Enabled = true;
                gunLoadoutComboBox3.Enabled = true;
                gunLoadoutComboBox4.Enabled = false;
                gunLoadoutComboBox5.Enabled = false;
                gunLoadoutComboBox4.SelectedIndex = 0;
                gunLoadoutComboBox5.SelectedIndex = 0;
            }
            if (gunCtrl.getListMax() == 4)
            {
                gunLoadoutComboBox1.Enabled = true;
                gunLoadoutComboBox2.Enabled = true;
                gunLoadoutComboBox3.Enabled = true;
                gunLoadoutComboBox4.Enabled = true;
                gunLoadoutComboBox5.Enabled = false;
                gunLoadoutComboBox5.SelectedIndex = 0;
            }
            if (gunCtrl.getListMax() == 5)
            {
                gunLoadoutComboBox1.Enabled = true;
                gunLoadoutComboBox2.Enabled = true;
                gunLoadoutComboBox3.Enabled = true;
                gunLoadoutComboBox4.Enabled = true;
                gunLoadoutComboBox5.Enabled = true;
            }
        }

        // Calculates overall base gun damage.
        private void aggregateGunDamage()
        {
            float gunDamage = ((int.Parse(totalGunDamageLabel1.Text)) + (int.Parse(totalGunDamageLabel2.Text)) + (int.Parse(totalGunDamageLabel3.Text)) + (int.Parse(totalGunDamageLabel4.Text)) + (int.Parse(totalGunDamageLabel5.Text)));
            aggregateDamageLabel.Text = gunDamage.ToString();
        }

        private int aggregateGunCost()
        {
            int total;


            // Lucidi Enforcer I = 200k + 8 crystals.
            // Lucidi Enforcer II = 400k + 14 crystals.
            // Lucidi Conqueror = 800k + 32.
            // Lucidi Plasma Thrower = 1.6mil + 40 crystals.

            total = gunCtrl.getAggregateCost();
            totalGunCostLabel.Text = total.ToString("N0");

            return total;
        }

        private int pardusGunECCost()
        {
            int exoticCrystalCost = 0;
            bool pweap = false;

            totalEMforGunsLabel.Visible = false;

            for (int i = 0; i < 5; i++)
            {
                if (gunCtrl.isPardusWeapon(i))
                {
                    pweap = true;
                    exoticCrystalCost += gunCtrl.getGunExoticCost(i);
                }
            }
            if (pweap == true)
            {
                totalEMforGunsLabel.Visible = true;
                totalEMforGunsLabel.Text = "+ " + exoticCrystalCost.ToString("N0");
            }

            return exoticCrystalCost;
        }

        private int freeSpaceRequiredForGuns()
        {
            totalFreeSpaceRequiredLabel.Text = ((int.Parse(gunWeightLabel1.Text)) + (int.Parse(gunWeightLabel2.Text)) + (int.Parse(gunWeightLabel3.Text)) + (int.Parse(gunWeightLabel4.Text)) + (int.Parse(gunWeightLabel5.Text))).ToString();
            return int.Parse(totalFreeSpaceRequiredLabel.Text);
        }

        private void gunPageClearPictureBox_Click(object sender, EventArgs e)
        {
            int gun1 = 1;
            int gun2 = 2;
            int gun3 = 3;
            int gun4 = 4;
            int gun5 = 5;

            ClearGun(ref gun1);
            ClearGun(ref gun2);
            ClearGun(ref gun3);
            ClearGun(ref gun4);
            ClearGun(ref gun5);
        }

        #endregion
        //End Of Gun-related Functions.

        #region crappystuff

        private string ConvertRankStringsToImagePaths(ref string rankName)
        {
            string path;

            switch (rankName)
            {
                // Federation
                case "Recruit":
                    path = Path.Combine("factions", "fedrank1.png");
                    return path;

                case "Private":
                    path = Path.Combine("factions", "fedrank2.png");
                    return path;

                case "Corporal":
                    path = Path.Combine("factions", "fedrank3.png");
                    return path;

                case "Sergeant":
                    path = Path.Combine("factions", "fedrank4.png");
                    return path;

                case "Sgt-Major":
                    path = Path.Combine("factions", "fedrank5.png");
                    return path;

                case "Major":
                    path = Path.Combine("factions", "fedrank6.png");
                    return path;

                case "Colonel":
                    path = Path.Combine("factions", "fedrank7.png");
                    return path;

                case "Lieutenant":
                    path = Path.Combine("factions", "fedrank8.png");
                    return path;

                case "Lt. Commander":
                    path = Path.Combine("factions", "fedrank9.png");
                    return path;

                case "Captain":
                    path = Path.Combine("factions", "fedrank10.png");
                    return path;

                case "Commodore":
                    path = Path.Combine("factions", "fedrank11.png");
                    return path;

                case "Rear Admiral":
                    path = Path.Combine("factions", "fedrank12.png");
                    return path;

                case "Admiral":
                    path = Path.Combine("factions", "fedrank13.png");
                    return path;

                case "Fleet Admiral":
                    path = Path.Combine("factions", "fedrank14.png");
                    return path;

                //Empire
                case "Outsider":
                    path = Path.Combine("factions", "emprank1.png");
                    return path;

                case "Serf":
                    path = Path.Combine("factions", "emprank2.png");
                    return path;

                case "Master/Mistress":
                    path = Path.Combine("factions", "emprank3.png");
                    return path;

                case "Sir/Dame":
                    path = Path.Combine("factions", "emprank4.png");
                    return path;

                case "Squire":
                    path = Path.Combine("factions", "emprank5.png");
                    return path;

                case "Lord/Lady":
                    path = Path.Combine("factions", "emprank6.png");
                    return path;

                case "Baron/Baroness":
                    path = Path.Combine("factions", "emprank7.png");
                    return path;

                case "Viscount/Viscountess":
                    path = Path.Combine("factions", "emprank8.png");
                    return path;

                case "Count/Countess":
                    path = Path.Combine("factions", "emprank9.png");
                    return path;

                case "Earl/Marchesa":
                    path = Path.Combine("factions", "emprank10.png");
                    return path;

                case "Marquis/Marchioness":
                    path = Path.Combine("factions", "emprank11.png");
                    return path;

                case "Duke/Duchess":
                    path = Path.Combine("factions", "emprank12.png");
                    return path;

                case "Prince/Princess":
                    path = Path.Combine("factions", "emprank13.png");
                    return path;

                case "King/Queen":
                    path = Path.Combine("factions", "emprank14.png");
                    return path;

                // Union
                case "Flunkey":
                    path = "factions/unirank1.png";
                    return path;

                case "Minion":
                    path = "factions/unirank2.png";
                    return path;

                case "Acolyte":
                    path = "factions/unirank3.png";
                    return path;

                case "Bookie":
                    path = "factions/unirank4.png";
                    return path;

                case "Collector":
                    path = "factions/unirank5.png";
                    return path;

                case "Accountant":
                    path = "factions/unirank6.png";
                    return path;

                case "Cleaner":
                    path = "factions/unirank7.png";
                    return path;

                case "Made Man/Made Woman":
                    path = "factions/unirank8.png";
                    return path;

                case "Chief":
                    path = "factions/unirank9.png";
                    return path;

                case "Kingpin":
                    path = "factions/unirank10.png";
                    return path;

                case "Nephew/Niece":
                    path = "factions/unirank11.png";
                    return path;

                case "Son/Daughter":
                    path = "factions/unirank12.png";
                    return path;

                case "Godfather/Godmother":
                    path = "factions/unirank13.png";
                    return path;

                case "Mogul":
                    path = "factions/unirank14.png";
                    return path;

                // Competency
                case "EPS Competency 1":
                case "TSS Competency 1":
                    path = "factions/neurank1.png";
                    return path;

                case "EPS Competency 2":
                case "TSS Competency 2":
                    path = "factions/neurank2.png";
                    return path;

                case "EPS Competency 3":
                case "TSS Competency 3":
                    path = "factions/neurank3.png";
                    return path;

                case "EPS Competency 4":
                case "TSS Competency 4":
                    path = "factions/neurank4.png";
                    return path;

                case "EPS Competency 5":
                case "TSS Competency 5":
                    path = "factions/neurank5.png";
                    return path;

                case "EPS Competency 6":
                case "TSS Competency 6":
                    path = "factions/neurank6.png";
                    return path;

                case "EPS Competency 7":
                case "TSS Competency 7":
                    path = "factions/neurank7.png";
                    return path;

                case "EPS Competency 8":
                case "TSS Competency 8":
                    path = "factions/neurank8.png";
                    return path;

                case "EPS Competency 9":
                case "TSS Competency 9":
                    path = "factions/neurank9.png";
                    return path;

                case "EPS Competency 10":
                case "TSS Competency 10":
                    path = "factions/neurank10.png";
                    return path;

                case "EPS Competency 11":
                case "TSS Competency 11":
                    path = "factions/neurank11.png";
                    return path;

                case "EPS Competency 12":
                case "TSS Competency 12":
                    path = "factions/neurank12.png";
                    return path;

                case "EPS Competency 13":
                case "TSS Competency 13":
                    path = "factions/neurank13.png";
                    return path;
            }
            return "E";
        }

        // Screen drawing refresh
        private void ScreenRefresh()
        {
            int shipSize;
            int shipArmor;
            int shipHull;
            int shipHullCapacity;
            int shieldPoints;
            int modeHullCapacity = 2;
            int modeSize = 3;
            int modeArmor = 4;
            int modeHull = 5;
            int modePoints = 0;

            shipSize = playerShip.GetShipData(ref modeSize, shipSelectBox.Text);
            shipArmor = playerShip.GetShipData(ref modeArmor, shipSelectBox.Text);
            shipHull = playerShip.GetShipData(ref modeHull, shipSelectBox.Text);
            shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
            shieldPoints = ShipEquipment.GetShieldData(ref modePoints, shieldSelectComboBox.Text);

            // Scale data values to fit bar as many are over "250"
            shipArmor = shipArmor / 4;
            shipHull = shipHull / 4;
            shieldPoints = shieldPoints / 4;
            shipHullCapacity = (int)Math.Ceiling((double)shipHullCapacity / 2);


            DrawStandardShipSizeBar(ref shipSize);
            DrawStandardShipArmorBar(ref shipArmor);
            DrawStandardShipHullBar(ref shipHull);
            DrawStandardShipFreeSpaceBar(ref shipHullCapacity);
            DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
            DrawStandardShipShieldBar(ref shieldPoints);

            if ((tabControl2.SelectedTab.ToString() == "TabPage: {Armor}") && (pieChartDrawn == false))
            {
                DrawArmorPieCharts();
                pieChartDrawn = true;
            }
            if (tabControl2.SelectedTab.ToString() != "TabPage: {Armor}")
            {
                pieChartDrawn = false;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            ScreenRefresh();
        }


        private void updateSummaryPage()
        {
            calculateTotalLoadoutSpace();
            calculateTotalLoadoutCost();
            freeSpaceRemaining();
            calculateRepairsAfterDeath();
            calculateDailyMaintenance();
            updateECCost();
        }

        private void updateECCost()
        {
            int gunECCost = pardusGunECCost();
            int modeStrength = 0;
            int armorStrength = GetArmorData(ref modeStrength);
            int armorECCost = calculatePardusArmor(ref armorStrength);

            totalECCostLabel.Text = (gunECCost + armorECCost).ToString();
        }
        private void screenRedrawCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (screenRedrawCheckBox.Checked == true)
            {
                timer1.Enabled = false;
            }
            if (screenRedrawCheckBox.Checked == false)
            {
                timer1.Enabled = true;
            }

        }

        private void disableShipPreviewCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (disableShipPreviewStarsCheckBox.Checked == true)
            {
                shipImageBox.BackgroundImage = null;
                fakeShipImageBox.BackgroundImage = null;
            }
            else
            {
                shipImageBox.BackgroundImage = Tame.Properties.Resources.stars;
                fakeShipImageBox.BackgroundImage = Tame.Properties.Resources.stars;
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            SetTameDirectoryPath();
            timer2.Start();

            // Set up non-automatically generated image paths:
            setupNoGenImages();

            versionLabel.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            startup = true;
            universeSelectComboBox.SelectedIndex = 0;
            LoadSettingsFromXmlFile();
            if (loadUniverseOnStartupCheckbox.Checked == true)
            {
                loadShipFromXML();
                loadPilotFromXML();
                loadCrewFromXML();
            }

            startup = false;

            if (screenRedrawCheckBox.Checked == false)
            {
                timer1.Enabled = true;
            }

            if (updatesCheckbox.Checked == true)
            {
                CheckForUpdates(true);
            }

            updateUsedDiskSpace();

            unsavedChanges = false;
        }

        private void setupNoGenImages()
        {
            string advancedSkill = "advanced_skills";
            string backgrounds = "backgrounds";
            cWeapSpecPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "c_weapon_specialization.jpg"));
            orgWeapSpecPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "o_weapon_specialization.jpg"));
            emWeapSpecPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "em_weapon_specialization.jpg"));

            defensiveCombatPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "defensive_combat.jpg"));
            offensiveCombatPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "offensive_combat.jpg"));
            agilityBoostPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "agility_boost.jpg"));
            cloakingBoostPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "cloaking_boost.jpg"));
            hullFortPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "hull_fortification.jpg"));
            shieldPoweringPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(advancedSkill, "shield_powering.jpg"));

            // Navigation Cost Tiles:
            spacePictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "space3.png"));
            energyPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "energymax.png"));
            viralCloudPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "viral_cloud1.png"));
            nebulaPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "nebula176.png"));
            asteroidsPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "asteroids6.png"));
            exoticPictureBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine(backgrounds, "exotic_matter1.png"));
        }

        private void updateUsedDiskSpace()
        {
            double diskSpaceUsed = 0.0;
            if (File.Exists(tameDirectory + "ship_orion.xml"))
            {
                FileInfo shipOrionXMLSize = new FileInfo(tameDirectory + "ship_orion.xml");
                diskSpaceUsed += (double)shipOrionXMLSize.Length;
            }
            if (File.Exists(tameDirectory + "ship_artemis.xml"))
            {
                FileInfo shipArtemisXMLSize = new FileInfo(tameDirectory + "ship_artemis.xml");
                diskSpaceUsed += (double)shipArtemisXMLSize.Length;
            }
            if (File.Exists(tameDirectory + "ship_pegasus.xml"))
            {
                FileInfo shipPegXMLSize = new FileInfo(tameDirectory + "ship_pegasus.xml");
                diskSpaceUsed += (double)shipPegXMLSize.Length;
            }
            if (File.Exists(settingsFile))
            {
                FileInfo settingsXmlSize = new FileInfo(settingsFile);
                diskSpaceUsed = (double)(settingsXmlSize.Length);
            }
            if (File.Exists(tameDirectory + "pilot_orion.xml"))
            {
                FileInfo pilotXML = new FileInfo(tameDirectory + "pilot_orion.xml");
                diskSpaceUsed += (double)(pilotXML.Length);
            }
            if (File.Exists(tameDirectory + "pilot_artemis.xml"))
            {
                FileInfo pilotXML = new FileInfo(tameDirectory + "pilot_artemis.xml");
                diskSpaceUsed += (double)(pilotXML.Length);
            }
            if (File.Exists(tameDirectory + "pilot_pegasus.xml"))
            {
                FileInfo pilotXML = new FileInfo(tameDirectory + "pilot_pegasus.xml");
                diskSpaceUsed += (double)(pilotXML.Length);
            }
            if (File.Exists(tameDirectory + "crew_orion.xml"))
            {
                FileInfo crewXML = new FileInfo(tameDirectory + "crew_orion.xml");
                diskSpaceUsed += (double)(crewXML.Length);
            }
            if (File.Exists(tameDirectory + "crew_artemis.xml"))
            {
                FileInfo crewXML = new FileInfo(tameDirectory + "crew_artemis.xml");
                diskSpaceUsed += (double)(crewXML.Length);
            }
            if (File.Exists(tameDirectory + "crew_pegasus.xml"))
            {
                FileInfo crewXML = new FileInfo(tameDirectory + "crew_pegasus.xml");
                diskSpaceUsed += (double)(crewXML.Length);
            }

            if (diskSpaceUsed < 1000)
            {
                diskSpaceUsedLabel.Text = (diskSpaceUsed.ToString("N0") + " Bytes.");
            }
            if ((diskSpaceUsed > 1000) && (diskSpaceUsed < 1000000))
            {
                diskSpaceUsed = (diskSpaceUsed / 1000);
                diskSpaceUsedLabel.Text = (diskSpaceUsed.ToString("N1") + " Kilobytes.");
            }
            if ((diskSpaceUsed > 1000000))
            {
                diskSpaceUsedLabel.Text = ">1 Megabyte. Error?";
            }
        }

        private void CheckForRankRequirementConflicts()
        {
            int modeShipRank = 7;
            int modeDriveRank = 6;
            int modeArmorRank = 2;
            int modeShieldRank = 4;
            int numberOfNotes = 0;
            int modeMissileRank = 5;

            string missile1 = missileLoadoutComboBox1.Name.ToString();
            string missile2 = missileLoadoutComboBox2.Name.ToString();
            string missile3 = missileLoadoutComboBox3.Name.ToString();
            string missile4 = missileLoadoutComboBox4.Name.ToString();
            string missile5 = missileLoadoutComboBox5.Name.ToString();
            string missile6 = missileLoadoutComboBox6.Name.ToString();
            string missile7 = missileLoadoutComboBox7.Name.ToString();
            string missile8 = missileLoadoutComboBox8.Name.ToString();
            string missile9 = missileLoadoutComboBox9.Name.ToString();
            string missile10 = missileLoadoutComboBox10.Name.ToString();
            string missile11 = missileLoadoutComboBox11.Name.ToString();
            string missile12 = missileLoadoutComboBox12.Name.ToString();
            string missile13 = missileLoadoutComboBox13.Name.ToString();
            string missile14 = missileLoadoutComboBox14.Name.ToString();
            string missile15 = missileLoadoutComboBox15.Name.ToString();
            string missile16 = missileLoadoutComboBox16.Name.ToString();
            string missile17 = missileLoadoutComboBox17.Name.ToString();
            string missile18 = missileLoadoutComboBox18.Name.ToString();
            string missile19 = missileLoadoutComboBox19.Name.ToString();
            string missile20 = missileLoadoutComboBox20.Name.ToString();
            string missile21 = missileLoadoutComboBox21.Name.ToString();
            string missile22 = missileLoadoutComboBox22.Name.ToString();
            string missile23 = missileLoadoutComboBox23.Name.ToString();
            string missile24 = missileLoadoutComboBox24.Name.ToString();
            string missile25 = missileLoadoutComboBox25.Name.ToString();


            totalNotesLabel.Text = "";

            string noreq = "0";
            string federation = "1";
            string empire = "2";
            string union = "3";
            string tss = "4";
            string eps = "5";
            int org = 1;
            int em = 2;

            string shipRequirement = playerShip.GetShipData(ref modeShipRank, shipSelectBox.Text).ToString();
            string gun1Requirement = gunCtrl.getGunRankPath(0);
            string gun2Requirement = gunCtrl.getGunRankPath(1);
            string gun3Requirement = gunCtrl.getGunRankPath(2);
            string gun4Requirement = gunCtrl.getGunRankPath(3);
            string gun5Requirement = gunCtrl.getGunRankPath(4);
            string driveRequirement = ShipEquipment.GetDriveData(ref modeDriveRank, driveSelectBox.Text).ToString();
            string armorRequirement = GetArmorData(ref modeArmorRank).ToString();
            string shieldRequirement = ShipEquipment.GetShieldData(ref modeShieldRank, shieldSelectComboBox.Text).ToString();
            string missileRequirement1 = GetMissileData(ref modeMissileRank, ref missile1).ToString();
            string missileRequirement2 = GetMissileData(ref modeMissileRank, ref missile2).ToString();
            string missileRequirement3 = GetMissileData(ref modeMissileRank, ref missile3).ToString();
            string missileRequirement4 = GetMissileData(ref modeMissileRank, ref missile4).ToString();
            string missileRequirement5 = GetMissileData(ref modeMissileRank, ref missile5).ToString();
            string missileRequirement6 = GetMissileData(ref modeMissileRank, ref missile6).ToString();
            string missileRequirement7 = GetMissileData(ref modeMissileRank, ref missile7).ToString();
            string missileRequirement8 = GetMissileData(ref modeMissileRank, ref missile8).ToString();
            string missileRequirement9 = GetMissileData(ref modeMissileRank, ref missile9).ToString();
            string missileRequirement10 = GetMissileData(ref modeMissileRank, ref missile10).ToString();
            string missileRequirement11 = GetMissileData(ref modeMissileRank, ref missile11).ToString();
            string missileRequirement12 = GetMissileData(ref modeMissileRank, ref missile12).ToString();
            string missileRequirement13 = GetMissileData(ref modeMissileRank, ref missile13).ToString();
            string missileRequirement14 = GetMissileData(ref modeMissileRank, ref missile14).ToString();
            string missileRequirement15 = GetMissileData(ref modeMissileRank, ref missile15).ToString();
            string missileRequirement16 = GetMissileData(ref modeMissileRank, ref missile16).ToString();
            string missileRequirement17 = GetMissileData(ref modeMissileRank, ref missile17).ToString();
            string missileRequirement18 = GetMissileData(ref modeMissileRank, ref missile18).ToString();
            string missileRequirement19 = GetMissileData(ref modeMissileRank, ref missile19).ToString();
            string missileRequirement20 = GetMissileData(ref modeMissileRank, ref missile20).ToString();
            string missileRequirement21 = GetMissileData(ref modeMissileRank, ref missile21).ToString();
            string missileRequirement22 = GetMissileData(ref modeMissileRank, ref missile22).ToString();
            string missileRequirement23 = GetMissileData(ref modeMissileRank, ref missile23).ToString();
            string missileRequirement24 = GetMissileData(ref modeMissileRank, ref missile24).ToString();
            string missileRequirement25 = GetMissileData(ref modeMissileRank, ref missile25).ToString();

            int modeHullCap = 2;
            int shipHullCap = playerShip.GetShipData(ref modeHullCap, shipSelectBox.Text);
            int freeSpaceRemaining = 0;

            // Check for XP values that will interfere with faction prefixes 0,1,2,3,5.
            if ((shipRequirement == "0") || (shipRequirement == "2220") || (shipRequirement == "11460") || ((shipRequirement == "12600") || (shipRequirement == "25560") || (shipRequirement == "7200") || (shipRequirement == "94500") || (shipRequirement == "102000") || (shipRequirement == "177000")) || (shipRequirement == "299700") || (shipRequirement == "509850") || (shipRequirement == "1368000"))
            {
                shipRequirement = "0";
            }
            // Check for items in the shipselectbox that are actually not ships.
            if ((shipSelectBox.Text == ":: Select Ship ::") || (shipSelectBox.Text == "Neutral Ships") || (shipSelectBox.Text == "Federation Ships") || (shipSelectBox.Text == "Empire Ships") || (shipSelectBox.Text == "Union Ships") || (shipSelectBox.Text == "TSS Ships") || (shipSelectBox.Text == "EPS Ships"))
            {
                shipRequirement = "9";
            }

            issuesListBox.Items.Clear();

            // Free space
            freeSpaceRemaining = (shipHullCap - calculateTotalLoadoutSpace());

            if ((freeSpaceRemaining <= 0) && (shipSelectBox.Text != ""))
            {
                if (issuesListBox.Items.Contains("No Free Space"))
                {
                }
                else
                {
                    issuesListBox.Items.Add("No Free Space");
                }
                numberOfNotes++;
            }
            if (freeSpaceRemaining > 0)
            {
                if (issuesListBox.Items.Contains("No Free Space"))
                {
                    issuesListBox.Items.Remove("No Free Space");
                }
            }


            // Federation Ships
            if (shipRequirement.StartsWith(federation))
            {
                if (fedRadioButton.Checked != true)
                {
                    if (issuesListBox.Items.Contains("Your ship is Federal, your pilot bio says you're not."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your ship is Federal, your pilot bio says you're not.");
                    }
                    numberOfNotes++;
                }

                if ((gun1Requirement != null) || (gun2Requirement != null) || (gun3Requirement != null) || (gun4Requirement != null) || (gun5Requirement != null))
                {
                    if (issuesListBox.Items.Contains("You can't fit Imperial Guns on a Federal Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Imperial Guns on a Federal Ship!");
                    }
                    numberOfNotes++;
                }
                if (armorRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit Union Armor on a Federal Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Union Armor on a Federal Ship!");
                    }
                    numberOfNotes++;
                }
                if (armorRequirement.StartsWith(noreq))
                {
                    if (issuesListBox.Items.Contains("You can't fit Union Armor on a Federal Ship!"))
                    {
                        issuesListBox.Items.Remove("You can't fit Union Armor on a Federal Ship!");
                    }
                }
                if (shieldRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Shield on a Federal Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Shield on a Federal Ship!");
                    }
                    numberOfNotes++;
                }
                if ((missileRequirement1.StartsWith(empire)) || (missileRequirement2.StartsWith(empire)) || (missileRequirement3.StartsWith(empire)) || (missileRequirement4.StartsWith(empire)) || (missileRequirement5.StartsWith(empire)) || (missileRequirement6.StartsWith(empire)) || (missileRequirement7.StartsWith(empire)) ||
                    (missileRequirement8.StartsWith(empire)) || (missileRequirement9.StartsWith(empire)) || (missileRequirement10.StartsWith(empire)) || (missileRequirement11.StartsWith(empire)) || (missileRequirement12.StartsWith(empire)) || (missileRequirement13.StartsWith(empire)) || (missileRequirement14.StartsWith(empire)) ||
                    (missileRequirement15.StartsWith(empire)) || (missileRequirement16.StartsWith(empire)) || (missileRequirement17.StartsWith(empire)) || (missileRequirement18.StartsWith(empire)) || (missileRequirement19.StartsWith(empire)) || (missileRequirement20.StartsWith(empire)) || (missileRequirement21.StartsWith(empire)) ||
                     (missileRequirement22.StartsWith(empire)) || (missileRequirement23.StartsWith(empire)) || (missileRequirement24.StartsWith(empire)) || (missileRequirement25.StartsWith(empire)))
                {
                    if (issuesListBox.Items.Contains("You can't fit Empire missiles on a Federal Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Empire missiles on a Federal Ship");
                    }
                    numberOfNotes++;
                }
                if ((gyroStabiliserComboBox.Text == "Gyro Stabilizer I") || (gyroStabiliserComboBox.Text == "Gyro Stabilizer II") || (ecmJammerSelectBox.Text == "Strong ECM Jammer") || (eccmJammerCheckBox.Checked == true) || ((fluxCapacitorSelectBox.Text != ":: No Capacitor ::")&& (fluxCapacitorSelectBox.Text != "")) || (keyOfSheppardCheckBox.Checked == true) || (cloakerSelectBox.Text == "Cloaking Device") || (interferometerSelectBox.Text == "Single-Wave Interferometer" || (interferometerSelectBox.Text == "Dual-Wave Interferormeter")))
                {
                    if (issuesListBox.Items.Contains("You can't Fit a Union Device on a Federal Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't Fit a Union Device on a Federal Ship");
                    }
                    numberOfNotes++;
                }
                if ((epsContrabandScannerCheckBox.Checked == true) || (epsContrabandDroneCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't Fit EPS Equipment on a Federal Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't Fit EPS Equipment on a Federal Ship");
                    }
                    numberOfNotes++;
                }
                if ((cloakerSelectBox.Text != ":: No Cloaker ::") || (interferometerSelectBox.Text != ":: No Interferometer ::") || (dampingFieldSelectBox.Text != ":: No Damping Field ::") || (dematSelectBox.Text != ":: No Dematerializer ::") || (bodypartMaskerCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't Fit TSS Equipment on a Federal Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't Fit TSS Equipment on a Federal Ship");
                    }
                    numberOfNotes++;
                }

                totalNotesLabel.Text = numberOfNotes.ToString();
            }

            //Union Ships
            if (shipRequirement.StartsWith(union))
            {
                if (uniRadioButton.Checked != true)
                {
                    if (issuesListBox.Items.Contains("Your ship is Union, your pilot bio says you're not."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your ship is Union, your pilot bio says you're not.");
                    }
                    numberOfNotes++;
                }
                if ((gun1Requirement != null) || (gun2Requirement != null) || (gun3Requirement != null) || (gun4Requirement != null) || (gun5Requirement != null))
                {
                    if (issuesListBox.Items.Contains("You can't fit Imperial Guns on a Union Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Imperial Guns on a Union Ship!");
                    }
                    numberOfNotes++;
                }
                if (driveRequirement.StartsWith(federation))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Federal Drive on a Union ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Federal Drive on a Union ship!");
                    }
                    numberOfNotes++;
                }
                if ((missileRequirement1.StartsWith(empire)) || (missileRequirement2.StartsWith(empire)) || (missileRequirement3.StartsWith(empire)) || (missileRequirement4.StartsWith(empire)) || (missileRequirement5.StartsWith(empire)) || (missileRequirement6.StartsWith(empire)) || (missileRequirement7.StartsWith(empire)) ||
    (missileRequirement8.StartsWith(empire)) || (missileRequirement9.StartsWith(empire)) || (missileRequirement10.StartsWith(empire)) || (missileRequirement11.StartsWith(empire)) || (missileRequirement12.StartsWith(empire)) || (missileRequirement13.StartsWith(empire)) || (missileRequirement14.StartsWith(empire)) ||
    (missileRequirement15.StartsWith(empire)) || (missileRequirement16.StartsWith(empire)) || (missileRequirement17.StartsWith(empire)) || (missileRequirement18.StartsWith(empire)) || (missileRequirement19.StartsWith(empire)) || (missileRequirement20.StartsWith(empire)) || (missileRequirement21.StartsWith(empire)) ||
     (missileRequirement22.StartsWith(empire)) || (missileRequirement23.StartsWith(empire)) || (missileRequirement24.StartsWith(empire)) || (missileRequirement25.StartsWith(empire)))
                {
                    if (issuesListBox.Items.Contains("You can't fit Empire missiles on a Union Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Empire missiles on a Union Ship");
                    }
                    numberOfNotes++;
                }
                if ((epsContrabandScannerCheckBox.Checked == true) || (epsContrabandDroneCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't fit EPS Equipment on a Union Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit EPS Equipment on a Union Ship");
                    }
                    numberOfNotes++;
                }
                if ((cloakerSelectBox.Text == "Improved Cloaking Device") || (bodypartMaskerCheckBox.Checked == true) || (interferometerSelectBox.Text == "Triple-Wave Interferometer") || (dampingFieldSelectBox.Text != ":: No Damping Field ::") || (dematSelectBox.Text != ":: No Dematerializer ::"))
                {
                    if (issuesListBox.Items.Contains("You can't fit TSS Equipment on a Union Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit TSS Equipment on a Union Ship");
                    }
                    numberOfNotes++;
                }
                totalNotesLabel.Text = numberOfNotes.ToString();
            }

            // Empire Ships
            if (shipRequirement.StartsWith(empire))
            {
                if (empRadioButton.Checked != true)
                {
                    if (issuesListBox.Items.Contains("Your ship is Imperial, your pilot bio says you're not."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your ship is Imperial, your pilot bio says you're not.");
                    }
                    numberOfNotes++;
                }
                if (driveRequirement.StartsWith(federation))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Federal Drive on an Imperial ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Federal Drive on an Imperial ship!");
                    }
                    numberOfNotes++;
                }
                if (armorRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit Union Armor on an Imperial Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Union Armor on an Imperial Ship!");
                    }
                    numberOfNotes++;
                }
                if (shieldRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Shield on an Imperial Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Shield on an Imperial Ship!");
                    }
                    numberOfNotes++;
                }
                if ((gyroStabiliserComboBox.Text == "Gyro Stabilizer I") || (gyroStabiliserComboBox.Text == "Gyro Stabilizer II") || (ecmJammerSelectBox.Text == "Strong ECM Jammer") || (eccmJammerCheckBox.Checked == true) || ((fluxCapacitorSelectBox.Text != ":: No Capacitor ::") && (fluxCapacitorSelectBox.Text != "")) || (keyOfSheppardCheckBox.Checked == true) || (cloakerSelectBox.Text == "Cloaking Device") || (interferometerSelectBox.Text == "Single-Wave Interferometer" || (interferometerSelectBox.Text == "Dual-Wave Interferormeter")))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Device on an Imperial Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Device on an Imperial Ship");
                    }
                    numberOfNotes++;
                }
                if ((epsContrabandScannerCheckBox.Checked == true) || (epsContrabandDroneCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't fit EPS Equipment on an Imperial Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit EPS Equipment on an Imperial Ship");
                    }
                    numberOfNotes++;
                }
                if ((cloakerSelectBox.Text != ":: No Cloaker ::") || (bodypartMaskerCheckBox.Checked == true) || (interferometerSelectBox.Text != ":: No Interferometer ::") || (dampingFieldSelectBox.Text != ":: No Damping Field ::") || (dematSelectBox.Text != ":: No Dematerializer ::"))
                {
                    if (issuesListBox.Items.Contains("You can't fit TSS Equipment on an Imperial Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit TSS Equipment on an Imperial Ship");
                    }
                    numberOfNotes++;
                }
                totalNotesLabel.Text = numberOfNotes.ToString();
            }

            // TSS Ships
            if (shipRequirement.StartsWith(tss))
            {
                if (tssRadioButton.Checked != true)
                {
                    if (issuesListBox.Items.Contains("Your ship is TSS, your pilot bio says you're not."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your ship is TSS, your pilot bio says you're not.");
                    }
                    numberOfNotes++;
                }
                if ((gun1Requirement != null) || (gun2Requirement != null) || (gun3Requirement != null) || (gun4Requirement != null) || (gun5Requirement != null))
                {
                    if (issuesListBox.Items.Contains("You can't fit Imperial Guns on a TSS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Imperial Guns on a TSS Ship!");
                    }
                    numberOfNotes++;
                }
                if (driveRequirement.StartsWith(federation))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Federal Drive on a TSS ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Federal Drive on a TSS ship!");
                    }
                    numberOfNotes++;
                }
                if (armorRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit Union Armor on a TSS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Union Armor on a TSS Ship!");
                    }
                    numberOfNotes++;
                }
                if (shieldRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Shield on a TSS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Shield on a TSS Ship!");
                    }
                    numberOfNotes++;
                }
                if ((missileRequirement1.StartsWith(empire)) || (missileRequirement2.StartsWith(empire)) || (missileRequirement3.StartsWith(empire)) || (missileRequirement4.StartsWith(empire)) || (missileRequirement5.StartsWith(empire)) || (missileRequirement6.StartsWith(empire)) || (missileRequirement7.StartsWith(empire)) ||
    (missileRequirement8.StartsWith(empire)) || (missileRequirement9.StartsWith(empire)) || (missileRequirement10.StartsWith(empire)) || (missileRequirement11.StartsWith(empire)) || (missileRequirement12.StartsWith(empire)) || (missileRequirement13.StartsWith(empire)) || (missileRequirement14.StartsWith(empire)) ||
    (missileRequirement15.StartsWith(empire)) || (missileRequirement16.StartsWith(empire)) || (missileRequirement17.StartsWith(empire)) || (missileRequirement18.StartsWith(empire)) || (missileRequirement19.StartsWith(empire)) || (missileRequirement20.StartsWith(empire)) || (missileRequirement21.StartsWith(empire)) ||
     (missileRequirement22.StartsWith(empire)) || (missileRequirement23.StartsWith(empire)) || (missileRequirement24.StartsWith(empire)) || (missileRequirement25.StartsWith(empire)))
                {
                    if (issuesListBox.Items.Contains("You can't fit Empire missiles on a TSS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Empire missiles on a TSS Ship!");
                    }
                    numberOfNotes++;
                }
                if ((gyroStabiliserComboBox.Text == "Gyro Stabilizer I") || (gyroStabiliserComboBox.Text == "Gyro Stabilizer II") || (ecmJammerSelectBox.Text == "Strong ECM Jammer") || (eccmJammerCheckBox.Checked == true) || ((fluxCapacitorSelectBox.Text != ":: No Capacitor ::") && (fluxCapacitorSelectBox.Text != "")) || (keyOfSheppardCheckBox.Checked == true) || (interferometerSelectBox.Text == "Single-Wave Interferometer" || (interferometerSelectBox.Text == "Dual-Wave Interferormeter")))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Device on a TSS Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Device on a TSS Ship");
                    }
                    numberOfNotes++;
                }
                if ((epsContrabandScannerCheckBox.Checked == true) || (epsContrabandDroneCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't fit EPS Equipment on a TSS Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit EPS Equipment on a TSS Ship");
                    }
                    numberOfNotes++;
                }
                totalNotesLabel.Text = numberOfNotes.ToString();
            }

            // EPS Ships
            if (shipRequirement.StartsWith(eps))
            {
                if (epsRadioButton.Checked != true)
                {
                    if (issuesListBox.Items.Contains("Your ship is EPS, your pilot bio says you're not."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your ship is EPS, your pilot bio says you're not.");
                    }
                    numberOfNotes++;
                }
                if ((gun1Requirement != null) || (gun2Requirement != null) || (gun3Requirement != null) || (gun4Requirement != null) || (gun5Requirement != null))
                {
                    if (issuesListBox.Items.Contains("You can't fit Imperial Guns on an EPS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Imperial Guns on an EPS Ship!");
                    }
                    numberOfNotes++;
                }
                if (driveRequirement.StartsWith(federation))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Federal Drive on an EPS playerShip."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Federal Drive on an EPS playerShip.");
                    }
                    numberOfNotes++;
                }
                if (armorRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit Union Armor on an EPS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Union Armor on an EPS Ship!");
                    }
                    numberOfNotes++;
                }
                if (shieldRequirement.StartsWith(union))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Shield on an EPS Ship!"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Shield on an EPS Ship!");
                    }
                    numberOfNotes++;
                }
                if ((missileRequirement1.StartsWith(empire)) || (missileRequirement2.StartsWith(empire)) || (missileRequirement3.StartsWith(empire)) || (missileRequirement4.StartsWith(empire)) || (missileRequirement5.StartsWith(empire)) || (missileRequirement6.StartsWith(empire)) || (missileRequirement7.StartsWith(empire)) ||
    (missileRequirement8.StartsWith(empire)) || (missileRequirement9.StartsWith(empire)) || (missileRequirement10.StartsWith(empire)) || (missileRequirement11.StartsWith(empire)) || (missileRequirement12.StartsWith(empire)) || (missileRequirement13.StartsWith(empire)) || (missileRequirement14.StartsWith(empire)) ||
    (missileRequirement15.StartsWith(empire)) || (missileRequirement16.StartsWith(empire)) || (missileRequirement17.StartsWith(empire)) || (missileRequirement18.StartsWith(empire)) || (missileRequirement19.StartsWith(empire)) || (missileRequirement20.StartsWith(empire)) || (missileRequirement21.StartsWith(empire)) ||
     (missileRequirement22.StartsWith(empire)) || (missileRequirement23.StartsWith(empire)) || (missileRequirement24.StartsWith(empire)) || (missileRequirement25.StartsWith(empire)))
                {
                    if (issuesListBox.Items.Contains("You can't fit Empire missiles on an EPS Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit Empire missiles on an EPS Ship");
                    }
                    numberOfNotes++;
                }
                if ((gyroStabiliserComboBox.Text == "Gyro Stabilizer I") || (gyroStabiliserComboBox.Text == "Gyro Stabilizer II") || (ecmJammerSelectBox.Text == "Strong ECM Jammer") || (eccmJammerCheckBox.Checked == true) || ((fluxCapacitorSelectBox.Text != ":: No Capacitor ::") && (fluxCapacitorSelectBox.Text != "")) || (keyOfSheppardCheckBox.Checked == true) || (cloakerSelectBox.Text == "Cloaking Device") || (interferometerSelectBox.Text == "Single-Wave Interferometer" || (interferometerSelectBox.Text == "Dual-Wave Interferormeter")))
                {
                    if (issuesListBox.Items.Contains("You can't fit a Union Device on an EPS Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit a Union Device on an EPS Ship");
                    }
                    numberOfNotes++;
                }
                if ((cloakerSelectBox.Text != ":: No Cloaker ::") || (bodypartMaskerCheckBox.Checked == true) || (interferometerSelectBox.Text != ":: No Interferometer ::") || (dampingFieldSelectBox.Text != ":: No Damping Field ::") || (dematSelectBox.Text != ":: No Dematerializer ::"))
                {
                    if (issuesListBox.Items.Contains("You can't fit TSS Equipment on an EPS Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit TSS Equipment on an EPS Ship");
                    }
                    numberOfNotes++;
                }
                totalNotesLabel.Text = numberOfNotes.ToString();
            }

            //Neutral Ships
            if (shipRequirement.StartsWith(noreq))
            {
                if ((epsContrabandScannerCheckBox.Checked == true) || (epsContrabandDroneCheckBox.Checked == true))
                {
                    if (issuesListBox.Items.Contains("You can't fit EPS Equipment on a Neutral Ship"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit EPS Equipment on a Neutral Ship");
                    }
                    numberOfNotes++;
                }
                if (((gun1Requirement != null) || (gun2Requirement != null) || (gun3Requirement != null) || (gun4Requirement != null) || (gun5Requirement != null) || (missileRequirement1.StartsWith(empire)) || (missileRequirement2.StartsWith(empire)) || (missileRequirement3.StartsWith(empire)) || (missileRequirement4.StartsWith(empire)) || (missileRequirement5.StartsWith(empire)) || (missileRequirement6.StartsWith(empire)) || (missileRequirement7.StartsWith(empire)) ||
    (missileRequirement8.StartsWith(empire)) || (missileRequirement9.StartsWith(empire)) || (missileRequirement10.StartsWith(empire)) || (missileRequirement11.StartsWith(empire)) || (missileRequirement12.StartsWith(empire)) || (missileRequirement13.StartsWith(empire)) || (missileRequirement14.StartsWith(empire)) ||
    (missileRequirement15.StartsWith(empire)) || (missileRequirement16.StartsWith(empire)) || (missileRequirement17.StartsWith(empire)) || (missileRequirement18.StartsWith(empire)) || (missileRequirement19.StartsWith(empire)) || (missileRequirement20.StartsWith(empire)) || (missileRequirement21.StartsWith(empire)) ||
     (missileRequirement22.StartsWith(empire)) || (missileRequirement23.StartsWith(empire)) || (missileRequirement24.StartsWith(empire)) || (missileRequirement25.StartsWith(empire))) && (empRadioButton.Checked != true))
                {
                    if (issuesListBox.Items.Contains("Pilot Bio indicateds you're not Imperial. Can't fit Imperial Equipment."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Pilot Bio indicates you're not Imperial. Can't fit Imperial Equipment.");
                    }
                    numberOfNotes++;
                }
                if ((driveRequirement.StartsWith(federation)) && (fedRadioButton.Checked != true))
                {
                    if (issuesListBox.Items.Contains("Pilot Bio indicates you're not Fed. Can't fit a Federal Drive"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Pilot Bio indicates you're not Fed. Can't fit a Federal Drive");
                    }
                    numberOfNotes++;
                }
                if ((((cloakerSelectBox.Text != ":: No Cloaker ::")&&(cloakerSelectBox.Text != "")) || ((interferometerSelectBox.Text != ":: No Interferometer ::")&&(interferometerSelectBox.Text != "")) || ((dampingFieldSelectBox.Text != ":: No Damping Field ::")&&(dampingFieldSelectBox.Text != "")) || ((dematSelectBox.Text != ":: No Dematerializer ::")&&(dematSelectBox.Text != ""))) && (tssRadioButton.Checked != true))
                {
                    if (issuesListBox.Items.Contains("Your Pilot Bio indicates you're not TSS. Can't fit TSS devices."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your Pilot Bio indicates you're not TSS. Can't fit TSS devices.");
                    }
                    numberOfNotes++;
                }
                if (((gyroStabiliserComboBox.Text == "Gyro Stabilizer I") || (armorRequirement.StartsWith(union)) || (shieldRequirement.StartsWith(union)) || (gyroStabiliserComboBox.Text == "Gyro Stabilizer II") || (ecmJammerSelectBox.Text == "Strong ECM Jammer") || (eccmJammerCheckBox.Checked == true) || ((fluxCapacitorSelectBox.Text != ":: No Capacitor ::") && (fluxCapacitorSelectBox.Text != "")) || (keyOfSheppardCheckBox.Checked == true) || (cloakerSelectBox.Text == "Cloaking Device") || (interferometerSelectBox.Text == "Single-Wave Interferometer" || (interferometerSelectBox.Text == "Dual-Wave Interferormeter"))) && (uniRadioButton.Checked != true))
                {
                    if (issuesListBox.Items.Contains("Your Pilot Bio indicates you're not Union. Can't fit Union devices."))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("Your Pilot Bio indicates you're not Union. Can't fit Union devices.");
                    }
                    numberOfNotes++;
                }
            }

            if ((gunCtrl.getGunType(0) == org) || (gunCtrl.getGunType(1) == org) || (gunCtrl.getGunType(2) == org) || (gunCtrl.getGunType(3) == org) || (gunCtrl.getGunType(4) == org))
            {
                if ((gunCtrl.getGunType(0) == em) || (gunCtrl.getGunType(1) == em) || (gunCtrl.getGunType(2) == em) || (gunCtrl.getGunType(3) == em) || (gunCtrl.getGunType(4) == em))
                {
                    if (issuesListBox.Items.Contains("You can't fit EM guns with Organic Guns"))
                    {
                    }
                    else
                    {
                        issuesListBox.Items.Add("You can't fit EM guns with Organic Guns");
                    }
                    numberOfNotes++;
                }
            }

            totalNotesLabel.Text = numberOfNotes.ToString();



            if (numberOfNotes < 1)
            {
                issuesPanel.BackColor = Color.LightGray;
                issuesPanel.BorderStyle = BorderStyle.None;
                issuesListBox.BackColor = Color.LightGray;
            }
            else
            {
                issuesPanel.BorderStyle = BorderStyle.FixedSingle;
                issuesPanel.BackColor = Color.IndianRed;
                issuesListBox.BackColor = Color.IndianRed;
            }

        }

        private void resizingCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (resizingCheckbox.Checked == true)
            {
                this.MaximumSize = new System.Drawing.Size(0, 0);
                this.MinimumSize = new System.Drawing.Size(0, 0);
            }
            if (resizingCheckbox.Checked == false)
            {
                this.MaximumSize = new System.Drawing.Size(745, 665);
                this.MinimumSize = new System.Drawing.Size(745, 665);
            }
        }

        private void cloakingFieldTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            imagePackPath = GetImagePackPath();

            if (cloakingFieldTypeComboBox.Text == "Energy")
            {
                inv_fieldrad = 1;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "energymax.png"));
            }
            if (cloakingFieldTypeComboBox.Text == "Viral Clouds")
            {
                inv_fieldrad = 2;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "viral_cloud14.png"));
            }
            if (cloakingFieldTypeComboBox.Text == "Nebula")
            {
                inv_fieldrad = 4;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "nebula207.png"));
            }
            if (cloakingFieldTypeComboBox.Text == "Asteroids")
            {
                inv_fieldrad = 8;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "asteroids4.png"));
            }
            if (cloakingFieldTypeComboBox.Text == "Space")
            {
                inv_fieldrad = 12;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "space20.png"));
            }
            if (cloakingFieldTypeComboBox.Text == "Exotic Matter")
            {
                inv_fieldrad = 50;
                tileTypeImageBox.ImageLocation = Path.Combine(imagePackPath, Path.Combine("backgrounds", "exotic_matter1.png"));
            }
        }

        private void calaculateCloakSkillButton_Click(object sender, EventArgs e)
        {
            // Make it so user doesn't need to refresh before calculating.
            refreshPilotTabSkills();

            int modeSize = 3;
            double shipSize = (double)playerShip.GetShipData(ref modeSize, shipSelectBox.Text);
            bool error = false;

            if ((shipSize == 0) && (inv_fieldrad > 0))
            {
                MessageBox.Show("You currently don't have a ship selected on the \"Designer\" tab. Can't do anything until this is corrected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                error = true;
            }
            if (error != true)
            {
                if ((shipSize == 0) && (inv_fieldrad == 0))
                {
                    MessageBox.Show("You currently don't have a ship selected on the \"Designer\" tab, you also don't have a tile-type selected. Can't do anything until both these issues are corrected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    error = true;
                }
            }
            if (error != true)
            {
                if ((shipSize > 0) && (inv_fieldrad == 0))
                {
                    MessageBox.Show("You currently don't have a tile type selected from the drop-down menu. Can't do anything until this is corrected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    error = true;
                }
            }

            if (error != true)
            {
                try
                {
                    double cloakskill = double.Parse(actualCLOLabel.Text);
                    double cloakingchance;
                    double cloakingchanceWithCloaker = 0;
                    cloakingchance = ((shipSize * inv_fieldrad) / (cloakskill * 10));
                    cloakingchance = 1 - cloakingchance;

                    if (cloakingchance < 0)
                    {
                        cloakingchance = 0;
                    }

                    // If cloaker is installed:
                    if (cloakerSelectBox.Text == "Cloaking Device")
                    {
                        cloakingchanceWithCloaker = cloakingchance + 0.25;
                    }
                    if (cloakerSelectBox.Text == "Improved Cloaking Device")
                    {
                        cloakingchanceWithCloaker = cloakingchance + 0.4;
                    }

                    if (cloakingchanceWithCloaker > 1)
                    {
                        cloakingchanceWithCloaker = 1;
                    }
                    if (cloakingchance > 1)
                    {
                        cloakingchance = 1;
                    }

                    cloakingChanceWithCloakerLabel.Text = cloakingchanceWithCloaker.ToString("P2");

                    if (cloakingchanceWithCloaker == 0)
                    {
                        cloakingChanceWithCloakerLabel.Text = "No Cloaker";
                    }

                    cloakingChanceLabel.Text = cloakingchance.ToString("P2");

                }
                catch (FormatException)
                {
                    MessageBox.Show("Cloaking Skill must be entered on the \"Pilot\" tab as a number. No punctuation, no letters no funny business - just numbers.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void calculateRequiredCloakSkill_Click(object sender, EventArgs e)
        {
            int modeSize = 3;
            int shipSize = playerShip.GetShipData(ref modeSize, shipSelectBox.Text);
            bool error = false;
            int chanceBoost = 0;

            if (cloakerSelectBox.SelectedIndex == 1)
            {
                chanceBoost += 25;
            }
            if (cloakerSelectBox.SelectedIndex == 2)
            {
                chanceBoost += 40;
            }

            if ((shipSize == 0) && (inv_fieldrad > 0))
            {
                MessageBox.Show("You currently don't have a ship selected on the \"Designer\" tab. Can't do anything until this is corrected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                error = true;
            }
            if (error != true)
            {
                if ((shipSize == 0) && (inv_fieldrad == 0))
                {
                    MessageBox.Show("You currently don't have a ship selected on the \"Designer\" tab, you also don't have a tile-type selected. Can't do anything until both these issues are corrected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    error = true;
                }
            }
            if (error != true)
            {
                if ((shipSize > 0) && (inv_fieldrad == 0))
                {
                    MessageBox.Show("You currently don't have a tile type selected from the drop-down menu. Can't do anything until this is corrected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    error = true;
                }
            }
            if (!error)
            {
                if (((cloakerSelectBox.Text == "") || (cloakerSelectBox.Text == ":: No Cloaker ::")) && (cloakingChanceSelector.Value == 100))
                {
                    MessageBox.Show("You wont reach 100% chance without a cloaker.", "Error");
                    error = true;
                }
            }
            if (error != true)
            {

                // Determine minimum skill required to cloak at all.
                double skill = (shipSize * (inv_fieldrad / 10));
                if (skill < 10)
                {
                    skill = 10;
                }

                // Determine desired chance:
                if (cloakingChanceSelector.Value > 100)
                {
                    cloakingChanceSelector.Value = 100;
                }
                double desiredChance = double.Parse(cloakingChanceSelector.Value.ToString());

                // Work out initial chance to succeed with the base skill:
                double cloakingChance = ((shipSize * inv_fieldrad) / (skill * 10));
                cloakingChance = 1 - cloakingChance;

                if (cloakingChance < 0)
                {
                    cloakingChance = 0;
                }

                // Start the loop:
                while (cloakingChance < (desiredChance / 100))
                {
                    cloakingChance -= chanceBoost;

                    skill = Math.Round(skill + 0.01, 2);
                    cloakingChance = ((shipSize * inv_fieldrad) / (skill * 10));
                    cloakingChance = 1 - cloakingChance;

                    if (cloakingChance < 0)
                    {
                        cloakingChance = 0;
                    }
                    cloakingChance += chanceBoost;
                }

                // Return skill value that matches desired cloaking chance.
                cloakingSkillRequiredLabel.Text = skill.ToString("N2");
                cloakingDaysLeft_SkillDesired.Value = (decimal) skill;
            }
        }

        private void cloakingDaysLeft_CalcButton_Click(object sender, EventArgs e)
        {
            int cloaker = cloakerSelectBox.SelectedIndex;
            bool error = false;
            string shipName = shipSelectBox.Text;
            int days = 0;
            int maxAp = 5760;
            bool empire = empRadioButton.Checked;
            try
            {
                double startSkill = double.Parse(actualCLOLabel.Text);
                double endSkill = (double)cloakingDaysLeft_SkillDesired.Value;


                if (startSkill >= endSkill)
                {
                    error = true;
                    cloakDaysLeft_DaysLeft.Text = "0";
                }

                if (assumeBestShipCheckbox.Checked == true)
                {
                    if (empire)
                    {
                        shipName = "- Shadow Stealth Craft";
                    }
                    else
                    {
                        shipName = "- Sabre";
                    }
                }

                if (!error)
                {                    
                    CloakingCalc cloaking = new CloakingCalc(inv_fieldrad, shipName, cloaker);
                    days = cloaking.determineDaysOfCloakTrainingLeft(startSkill, endSkill, maxAp);                    

                    cloakDaysLeft_DaysLeft.Text = days.ToString();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to parse Actual Cloaking skill: ", "Error");
                error = true;
            }
                 
        }

        private void cloakWorker_DoWork(object sender, DoWorkEventArgs e)
        {
           
            
        }

        private void cloakWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            
        }

        private void calculateTracorBeamChancesButton_Click(object sender, EventArgs e)
        {
            int modeSize = 3;
            double shipSize = (double)playerShip.GetShipData(ref modeSize, shipSelectBox.Text);
            double tractorChance;

            tractorChance = ((55 - 9 * Math.Log((shipSize - 4) / 4)) / 100);

            //Standard
            if ((((tractorChance) * 0.8) > 0.15) && (((tractorChance) * 0.8) < 0.40))
            {
                standardTractorBeamLabel.ForeColor = Color.DarkOrange;
            }
            if (((tractorChance) * 0.8) >= 0.40)
            {
                standardTractorBeamLabel.ForeColor = Color.Red;
            }
            if (((tractorChance) * 0.8) <= 0.15)
            {
                standardTractorBeamLabel.ForeColor = Color.Green;
            }

            // Advanced
            if (((tractorChance) > 0.15) && ((tractorChance) < 0.40))
            {
                advancedTractorBeamLabel.ForeColor = Color.OrangeRed;
            }
            if (tractorChance >= 0.40)
            {
                advancedTractorBeamLabel.ForeColor = Color.Red;
            }
            if (tractorChance <= 0.15)
            {
                advancedTractorBeamLabel.ForeColor = Color.Green;
            }
            standardTractorBeamLabel.Text = ((tractorChance) * 0.8).ToString("P2");
            advancedTractorBeamLabel.Text = (tractorChance).ToString("P2");


        }

        private void truthButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You can't HANDLE the truth", "The Truth");
        }

        private void armorComboxBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            int modeStrength = 0;
            int modeCost = 1;
            int modeRankRequirement = 2;
            int modeArmor = 4;
            int shipArmor = 0;

            int armorCost;
            int armorStrength;
            int armorRank;

            string rankImageString;
            string imagePackPath;
            string requiredRankImageURL;
            string armorImageURL;


            imagePackPath = GetImagePackPath();
            armorRank = GetArmorData(ref modeRankRequirement);
            rankImageString = rankData.ParseRankIDToString( armorRank);
            requiredRankImageURL = ConvertRankStringsToImagePaths(ref rankImageString);

            if (requiredRankImageURL != "E")
            {
                armorRankImageBox.Image = null;
                armorRankImageBox.ImageLocation = Path.Combine(imagePackPath, requiredRankImageURL);
            }
            else
            {
                armorRankImageBox.ImageLocation = null;
                armorRankImageBox.Image = Tame.Properties.Resources.xp_icon;
            }

            armorCost = GetArmorData(ref modeCost);
            armorStrength = GetArmorData(ref modeStrength);


            armorCostLabel.Text = armorCost.ToString("N0");
            armorStrengthLabel.Text = armorStrength.ToString();

            armorImageBox.BackColor = Color.LightGray;
            armorImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(armorComboBox.Text);
            armorImageURL = Path.Combine(imagePackPath, armorImageURL);
            armorImageBox.ImageLocation = armorImageURL;

            // Exotic crystals.
            armorECCostPanel.Visible = false;
            pardusArmorRetryButton.Visible = false;

            if ((armorComboBox.Text == "Pardus I") || (armorComboBox.Text == "Pardus II") || (armorComboBox.Text == "Pardus III") || (armorComboBox.Text == "Pardus IV") || (armorComboBox.Text == "Pardus V") || (armorComboBox.Text == "Pardus VI"))
            {
                calculatePardusArmor(ref armorStrength);
            }

            // Change tooltip + rank
            if ((armorComboBox.Text == "Ebidium (x6)") || (armorComboBox.Text == "Pardus VI"))
            {
                toolTip1.SetToolTip(this.armorRankImageBox, rankData.ParseRankIDToString( armorRank));
                armorRankImageBox.Image = null;
            }

            CheckForRankRequirementConflicts();

            //Work out effective armor
            shipArmor = playerShip.GetShipData(ref modeArmor, shipSelectBox.Text);
            effectiveArmorLabel.Text = ((shipArmor * armorStrength).ToString() + " (Effective).");
            DrawArmorPieCharts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private int calculatePardusArmor(ref int armorStrength)
        {
            try
            {
                int ECCost = 0;
                if (armorComboBox.SelectedIndex > 22)
                {
                    pardusArmorRetryButton.Visible = true;
                    armorECCostPanel.Visible = true;
                    int numberOfDays = (int)pardusArmorDurationUpDown.Value;

                    ECCost = (armorStrength * numberOfDays) / 2;
                    armorECCostLabel.Text = "+" + ECCost;
                }

                return ECCost;
            }
            catch (FormatException)
            {
                MessageBox.Show("Please enter the desired number of days as a number!", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return -1;
            }

        }

        #region CUSTOM_COLOURS

        private void resetCustomColoursToDefaultButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            DialogResult confirmDialogResult = MessageBox.Show("Are you sure you want to reset your custom colours to defaults?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (confirmDialogResult == DialogResult.Yes)
            {
                hullBrush.Color = Color.Blue;
                lightGrayBrush.Color = Color.LightGray;
                sizeBrush.Color = Color.Red;
                shieldBrush.Color = Color.Purple;
                armorBrush.Color = Color.Green;
                whiteBrush.Color = Color.White;
                orangeBrush.Color = Color.Orange;
                fancyb1.Color = Color.MidnightBlue;
                fancyb2.Color = Color.MediumVioletRed;
                fancyb3.Color = Color.MediumSeaGreen;
                totalSpaceBrush.Color = Color.Blue;
                usedSpaceBrush.Color = Color.Green;
                notEnoughSpaceBrush.Color = Color.Red;
            }
        }

        private void armorBarColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog armorBarColourDialog = new ColorDialog();
            armorBarColourDialog.Color = armorBrush.Color;
            armorBarColourDialog.ShowDialog();
            armorBrush.Color = armorBarColourDialog.Color;
        }

        private void sizeBarColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog sizeBarColourDialog = new ColorDialog();
            sizeBarColourDialog.Color = sizeBrush.Color;
            sizeBarColourDialog.ShowDialog();
            sizeBrush.Color = sizeBarColourDialog.Color;
        }

        private void hullBarColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog hullBarColourDialog = new ColorDialog();
            hullBarColourDialog.Color = hullBrush.Color;
            hullBarColourDialog.ShowDialog();
            hullBrush.Color = hullBarColourDialog.Color;
        }

        private void totalSpaceBarCustomColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog totalSpaceBarColourDialog = new ColorDialog();
            totalSpaceBarColourDialog.Color = totalSpaceBrush.Color;
            totalSpaceBarColourDialog.ShowDialog();
            totalSpaceBrush.Color = totalSpaceBarColourDialog.Color;
        }

        private void usedSpaceCustomColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog usedSpaceBarColourDialog = new ColorDialog();
            usedSpaceBarColourDialog.Color = usedSpaceBrush.Color;
            usedSpaceBarColourDialog.ShowDialog();
            usedSpaceBrush.Color = usedSpaceBarColourDialog.Color;
        }

        private void noSpaceCustomColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog noSpaceBarColourDialog = new ColorDialog();
            noSpaceBarColourDialog.Color = notEnoughSpaceBrush.Color;
            noSpaceBarColourDialog.ShowDialog();
            notEnoughSpaceBrush.Color = noSpaceBarColourDialog.Color;
        }

        private void shieldBarColourButton_Click(object sender, EventArgs e)
        {
            unsavedChanges = true;
            ColorDialog shieldBarColourDialog = new ColorDialog();
            shieldBarColourDialog.Color = shieldBrush.Color;
            shieldBarColourDialog.ShowDialog();
            shieldBrush.Color = shieldBarColourDialog.Color;
        }
        #endregion

        #region XML_HANDLING
        private void saveLoadoutButton_Click(object sender, EventArgs e)
        {
            if (shutdown != true)
            {
                DialogResult saveDialogResult = MessageBox.Show("Saving Ship Loadout: Doing this will overwrite the previously saved setup, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveDialogResult == DialogResult.Yes)
                {
                    unsavedChanges = false;
                    if (Directory.Exists(tameDirectory) != true)
                    {
                        System.IO.Directory.CreateDirectory(tameDirectory);
                    }
                    XmlTextWriter saveShip = new XmlTextWriter(shipFile, null);
                    saveShip.WriteStartDocument();
                    saveShip.WriteComment("Tame Ship Calc: Auto-Generated XML File. This file holds one saved ship loadout from the \"Designer\" tab");
                    saveShip.WriteStartElement("Root");
                    saveShip.WriteStartElement("savedShip");
                    saveShip.WriteStartAttribute("shipName");
                    saveShip.WriteString(shipSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gun1");
                    saveShip.WriteString(gunLoadoutComboBox1.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gun2");
                    saveShip.WriteString(gunLoadoutComboBox2.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gun3");
                    saveShip.WriteString(gunLoadoutComboBox3.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gun4");
                    saveShip.WriteString(gunLoadoutComboBox4.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gun5");
                    saveShip.WriteString(gunLoadoutComboBox5.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("drive");
                    saveShip.WriteString(driveSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("armor");
                    saveShip.WriteString(armorComboBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("shield");
                    saveShip.WriteString(shieldSelectComboBox.Text);
                    saveShip.WriteEndAttribute();
                    //Missiles
                    saveShip.WriteStartAttribute("missile1");
                    saveShip.WriteString(missileLoadoutComboBox1.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile2");
                    saveShip.WriteString(missileLoadoutComboBox2.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile3");
                    saveShip.WriteString(missileLoadoutComboBox3.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile4");
                    saveShip.WriteString(missileLoadoutComboBox4.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile5");
                    saveShip.WriteString(missileLoadoutComboBox5.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile6");
                    saveShip.WriteString(missileLoadoutComboBox6.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile7");
                    saveShip.WriteString(missileLoadoutComboBox7.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile8");
                    saveShip.WriteString(missileLoadoutComboBox8.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile9");
                    saveShip.WriteString(missileLoadoutComboBox9.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile10");
                    saveShip.WriteString(missileLoadoutComboBox10.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile11");
                    saveShip.WriteString(missileLoadoutComboBox11.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile12");
                    saveShip.WriteString(missileLoadoutComboBox12.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile13");
                    saveShip.WriteString(missileLoadoutComboBox13.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile14");
                    saveShip.WriteString(missileLoadoutComboBox14.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile15");
                    saveShip.WriteString(missileLoadoutComboBox15.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile16");
                    saveShip.WriteString(missileLoadoutComboBox16.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile17");
                    saveShip.WriteString(missileLoadoutComboBox17.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile18");
                    saveShip.WriteString(missileLoadoutComboBox18.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile19");
                    saveShip.WriteString(missileLoadoutComboBox19.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile20");
                    saveShip.WriteString(missileLoadoutComboBox20.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile21");
                    saveShip.WriteString(missileLoadoutComboBox21.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile22");
                    saveShip.WriteString(missileLoadoutComboBox22.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile23");
                    saveShip.WriteString(missileLoadoutComboBox23.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile24");
                    saveShip.WriteString(missileLoadoutComboBox24.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("missile25");
                    saveShip.WriteString(missileLoadoutComboBox25.Text);
                    saveShip.WriteEndAttribute();
                    // Special
                    saveShip.WriteStartAttribute("autoRefueller");
                    saveShip.WriteString(autoRefuelerCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("epod");
                    saveShip.WriteString(escapePodCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("fuelScoop");
                    saveShip.WriteString(fuelScoopCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("bussardRamscoop");
                    saveShip.WriteString(bussardRamscoopCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("magScoop");
                    saveShip.WriteString(magScoopCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("ambushTeleporter");
                    saveShip.WriteString(ambushTeleporterCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("teleporter");
                    saveShip.WriteString(teleporterComboBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("mapPack");
                    saveShip.WriteString(mapPackComboBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("bountyLink");
                    saveShip.WriteString(bountyLinkComboBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("gyro");
                    saveShip.WriteString(gyroStabiliserComboBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("ecmJammer");
                    saveShip.WriteString(ecmJammerSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("eccmJammer");
                    saveShip.WriteString(eccmJammerCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("fluxCapacitor");
                    saveShip.WriteString(fluxCapacitorSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("keyOfSheppard");
                    saveShip.WriteString(keyOfSheppardCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("EPSScanner");
                    saveShip.WriteString(epsContrabandScannerCheckBox.CheckState.ToString());
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("Cloaker");
                    saveShip.WriteString(cloakerSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("Interferometer");
                    saveShip.WriteString(interferometerSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("dampingField");
                    saveShip.WriteString(dampingFieldSelectBox.Text);
                    saveShip.WriteEndAttribute();
                    saveShip.WriteStartAttribute("dematerializer");
                    saveShip.WriteString(dematSelectBox.Text);
                    saveShip.WriteEndAttribute();

                    saveShip.WriteEndElement();
                    saveShip.WriteEndElement();
                    saveShip.WriteEndDocument();
                    saveShip.Close();
                }

            }
            else
            {

                if (Directory.Exists(tameDirectory))
                {
                    System.IO.Directory.CreateDirectory(tameDirectory);
                }
                XmlTextWriter saveShip = new XmlTextWriter(shipFile, null);
                saveShip.WriteStartDocument();
                saveShip.WriteComment("Tame Ship Calc: Auto-Generated XML File. This file holds one saved ship loadout from the \"Designer\" tab");
                saveShip.WriteStartElement("Root");
                saveShip.WriteStartElement("savedShip");
                saveShip.WriteStartAttribute("shipName");
                saveShip.WriteString(shipSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gun1");
                saveShip.WriteString(gunLoadoutComboBox1.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gun2");
                saveShip.WriteString(gunLoadoutComboBox2.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gun3");
                saveShip.WriteString(gunLoadoutComboBox3.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gun4");
                saveShip.WriteString(gunLoadoutComboBox4.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gun5");
                saveShip.WriteString(gunLoadoutComboBox5.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("drive");
                saveShip.WriteString(driveSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("armor");
                saveShip.WriteString(armorComboBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("shield");
                saveShip.WriteString(shieldSelectComboBox.Text);
                saveShip.WriteEndAttribute();
                //Missiles
                saveShip.WriteStartAttribute("missile1");
                saveShip.WriteString(missileLoadoutComboBox1.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile2");
                saveShip.WriteString(missileLoadoutComboBox2.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile3");
                saveShip.WriteString(missileLoadoutComboBox3.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile4");
                saveShip.WriteString(missileLoadoutComboBox4.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile5");
                saveShip.WriteString(missileLoadoutComboBox5.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile6");
                saveShip.WriteString(missileLoadoutComboBox6.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile7");
                saveShip.WriteString(missileLoadoutComboBox7.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile8");
                saveShip.WriteString(missileLoadoutComboBox8.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile9");
                saveShip.WriteString(missileLoadoutComboBox9.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile10");
                saveShip.WriteString(missileLoadoutComboBox10.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile11");
                saveShip.WriteString(missileLoadoutComboBox11.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile12");
                saveShip.WriteString(missileLoadoutComboBox12.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile13");
                saveShip.WriteString(missileLoadoutComboBox13.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile14");
                saveShip.WriteString(missileLoadoutComboBox14.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile15");
                saveShip.WriteString(missileLoadoutComboBox15.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile16");
                saveShip.WriteString(missileLoadoutComboBox16.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile17");
                saveShip.WriteString(missileLoadoutComboBox17.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile18");
                saveShip.WriteString(missileLoadoutComboBox18.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile19");
                saveShip.WriteString(missileLoadoutComboBox19.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile20");
                saveShip.WriteString(missileLoadoutComboBox20.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile21");
                saveShip.WriteString(missileLoadoutComboBox21.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile22");
                saveShip.WriteString(missileLoadoutComboBox22.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile23");
                saveShip.WriteString(missileLoadoutComboBox23.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile24");
                saveShip.WriteString(missileLoadoutComboBox24.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("missile25");
                saveShip.WriteString(missileLoadoutComboBox25.Text);
                saveShip.WriteEndAttribute();
                // Special
                saveShip.WriteStartAttribute("autoRefueller");
                saveShip.WriteString(autoRefuelerCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("epod");
                saveShip.WriteString(escapePodCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("fuelScoop");
                saveShip.WriteString(fuelScoopCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("bussardRamscoop");
                saveShip.WriteString(bussardRamscoopCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("magScoop");
                saveShip.WriteString(magScoopCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("ambushTeleporter");
                saveShip.WriteString(ambushTeleporterCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("teleporter");
                saveShip.WriteString(teleporterComboBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("mapPack");
                saveShip.WriteString(mapPackComboBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("bountyLink");
                saveShip.WriteString(bountyLinkComboBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("gyro");
                saveShip.WriteString(gyroStabiliserComboBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("ecmJammer");
                saveShip.WriteString(ecmJammerSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("eccmJammer");
                saveShip.WriteString(eccmJammerCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("fluxCapacitor");
                saveShip.WriteString(fluxCapacitorSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("keyOfSheppard");
                saveShip.WriteString(keyOfSheppardCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("EPSScanner");
                saveShip.WriteString(epsContrabandScannerCheckBox.CheckState.ToString());
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("Cloaker");
                saveShip.WriteString(cloakerSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("Interferometer");
                saveShip.WriteString(interferometerSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("dampingField");
                saveShip.WriteString(dampingFieldSelectBox.Text);
                saveShip.WriteEndAttribute();
                saveShip.WriteStartAttribute("dematerializer");
                saveShip.WriteString(dematSelectBox.Text);
                saveShip.WriteEndAttribute();

                saveShip.WriteEndElement();
                saveShip.WriteEndElement();
                saveShip.WriteEndDocument();
                saveShip.Close();

            }
            updateUsedDiskSpace();

        }

        private void deleteShipButton_Click(object sender, EventArgs e)
        {
            DialogResult deleteShipDialogResult = MessageBox.Show("Deleting Saved Ship Loadout: Doing this will permanently delete any previously saved setup, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deleteShipDialogResult == DialogResult.Yes)
            {
                if (Directory.Exists(tameDirectory))
                {
                    if (File.Exists(shipFile))
                    {
                        File.Delete(shipFile);
                    }
                }
                updateUsedDiskSpace();
            }
        }

        private void deleteAllLocalDataButton_Click(object sender, EventArgs e)
        {
            DialogResult deleteAllLocalDataDialogResult = MessageBox.Show("Doing this will permanently delete all local data, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deleteAllLocalDataDialogResult == DialogResult.Yes)
            {
                try
                {
                    // Need "true" to avoid IO exception - deletes all files and subdirectories. 
                    Directory.Delete(tameDirectory, true);
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Unable to locate directory - Contact Pigeon in Pegasus");
                }
                updateUsedDiskSpace();
            }

        }

        private void loadShipLoadoutButton_Click(object sender, EventArgs e)
        {
            if (startup != true)
            {
                DialogResult saveDialogResult = MessageBox.Show("Loading Saved Ship Loadout: Doing this will overwrite any design currently in the designer, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveDialogResult == DialogResult.Yes)
                {
                    loadShipFromXML();
                }
            }
            else
            {
                loadShipFromXML();
            }
        }

        private void loadShipFromXML()
        {
            if (Directory.Exists(tameDirectory))
            {
                if (File.Exists(shipFile))
                {
                    XmlTextReader loadShip = new XmlTextReader(shipFile);

                    // Read until end of file
                    while (loadShip.Read())
                    {
                        if (loadShip.Name == "savedShip")
                        {
                            shipSelectBox.Text = loadShip.GetAttribute(0);
                            gunLoadoutComboBox1.Text = loadShip.GetAttribute(1);
                            gunLoadoutComboBox2.Text = loadShip.GetAttribute(2);
                            gunLoadoutComboBox3.Text = loadShip.GetAttribute(3);
                            gunLoadoutComboBox4.Text = loadShip.GetAttribute(4);
                            gunLoadoutComboBox5.Text = loadShip.GetAttribute(5);
                            driveSelectBox.Text = loadShip.GetAttribute(6);
                            armorComboBox.Text = loadShip.GetAttribute(7);
                            shieldSelectComboBox.Text = loadShip.GetAttribute(8);
                            missileLoadoutComboBox1.Text = loadShip.GetAttribute(9);
                            missileLoadoutComboBox2.Text = loadShip.GetAttribute(10);
                            missileLoadoutComboBox3.Text = loadShip.GetAttribute(11);
                            missileLoadoutComboBox4.Text = loadShip.GetAttribute(12);
                            missileLoadoutComboBox5.Text = loadShip.GetAttribute(13);
                            missileLoadoutComboBox6.Text = loadShip.GetAttribute(14);
                            missileLoadoutComboBox7.Text = loadShip.GetAttribute(15);
                            missileLoadoutComboBox8.Text = loadShip.GetAttribute(16);
                            missileLoadoutComboBox9.Text = loadShip.GetAttribute(17);
                            missileLoadoutComboBox10.Text = loadShip.GetAttribute(18);
                            missileLoadoutComboBox11.Text = loadShip.GetAttribute(19);
                            missileLoadoutComboBox12.Text = loadShip.GetAttribute(20);
                            missileLoadoutComboBox13.Text = loadShip.GetAttribute(21);
                            missileLoadoutComboBox14.Text = loadShip.GetAttribute(22);
                            missileLoadoutComboBox15.Text = loadShip.GetAttribute(23);
                            missileLoadoutComboBox16.Text = loadShip.GetAttribute(24);
                            missileLoadoutComboBox17.Text = loadShip.GetAttribute(25);
                            missileLoadoutComboBox18.Text = loadShip.GetAttribute(26);
                            missileLoadoutComboBox19.Text = loadShip.GetAttribute(27);
                            missileLoadoutComboBox20.Text = loadShip.GetAttribute(28);
                            missileLoadoutComboBox21.Text = loadShip.GetAttribute(29);
                            missileLoadoutComboBox22.Text = loadShip.GetAttribute(30);
                            missileLoadoutComboBox23.Text = loadShip.GetAttribute(31);
                            missileLoadoutComboBox24.Text = loadShip.GetAttribute(32);
                            missileLoadoutComboBox25.Text = loadShip.GetAttribute(33);
                            //Special Equipment
                            if (loadShip.GetAttribute(34) == "Checked")
                            {
                                autoRefuelerCheckBox.Checked = true;
                            }
                            else
                            {
                                autoRefuelerCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(35) == "Checked")
                            {
                                escapePodCheckBox.Checked = true;
                            }
                            else
                            {
                                escapePodCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(36) == "Checked")
                            {
                                fuelScoopCheckBox.Checked = true;
                            }
                            else
                            {
                                fuelScoopCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(37) == "Checked")
                            {
                                bussardRamscoopCheckBox.Checked = true;
                            }
                            else
                            {
                                bussardRamscoopCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(38) == "Checked")
                            {
                                magScoopCheckBox.Checked = true;
                            }
                            else
                            {
                                magScoopCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(39) == "Checked")
                            {
                                ambushTeleporterCheckBox.Checked = true;
                            }
                            else
                            {
                                ambushTeleporterCheckBox.Checked = false;
                            }
                            teleporterComboBox.Text = loadShip.GetAttribute(40);
                            mapPackComboBox.Text = loadShip.GetAttribute(41);
                            bountyLinkComboBox.Text = loadShip.GetAttribute(42);
                            gyroStabiliserComboBox.Text = loadShip.GetAttribute(43);
                            ecmJammerSelectBox.Text = loadShip.GetAttribute(44);
                            if (loadShip.GetAttribute(45) == "Checked")
                            {
                                eccmJammerCheckBox.Checked = true;
                            }
                            else
                            {
                                eccmJammerCheckBox.Checked = false;
                            }
                            fluxCapacitorSelectBox.Text = loadShip.GetAttribute(46);
                            if (loadShip.GetAttribute(47) == "Checked")
                            {
                                keyOfSheppardCheckBox.Checked = true;
                            }
                            else
                            {
                                keyOfSheppardCheckBox.Checked = false;
                            }
                            if (loadShip.GetAttribute(48) == "Checked")
                            {
                                epsContrabandScannerCheckBox.Checked = true;
                            }
                            else
                            {
                                epsContrabandScannerCheckBox.Checked = false;
                            }
                            cloakerSelectBox.Text = loadShip.GetAttribute(49);
                            interferometerSelectBox.Text = loadShip.GetAttribute(50);
                            dampingFieldSelectBox.Text = loadShip.GetAttribute(51);
                            dematSelectBox.Text = loadShip.GetAttribute(52);
                        }

                    }
                    loadShip.Close();
                }
                else
                {
                    if (startup != true)
                    {
                        MessageBox.Show(string.Format("{0} could not be found. Does a previous save file exist?", shipFile), "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }


            }
            else
            {
                if (startup != true)
                {
                    MessageBox.Show("Directory could not be found. Does it exist?", "Directory Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }

        }

        private void saveSettingsButton_Click(object sender, EventArgs e)
        {
            if (shutdown != true)
            {
                DialogResult saveDialogResult = MessageBox.Show("Saving Settings: Doing this will overwrite the previously saved settings, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveDialogResult == DialogResult.Yes)
                {
                    SaveSettingsToXmlFile();
                }

            }
            else
            {
                SaveSettingsToXmlFile();
            }

            updateUsedDiskSpace();
        }

        private void SaveSettingsToXmlFile()
        {
            unsavedChanges = false;
            if (Directory.Exists(tameDirectory) != true)
            {
                Directory.CreateDirectory(tameDirectory);
            }
            XmlTextWriter saveSettings = new XmlTextWriter(settingsFile, null);
            saveSettings.WriteStartDocument();
            saveSettings.WriteComment("Tame Ship Calc: Auto-Generated XML File. This file holds the user's custom settings from the \"options\" tab");
            saveSettings.WriteStartElement("Root");

            saveSettings.WriteStartElement("customIPSettings", "");
            saveSettings.WriteStartAttribute("customIPCheckBox");
            saveSettings.WriteString(customIPCheckBox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("imagePackPath");
            saveSettings.WriteString(imagePackPath);
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("imagePackURLModified");
            saveSettings.WriteString(impackURLmodified.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up "customIPSettings"

            saveSettings.WriteStartElement("customColours", "");
            saveSettings.WriteStartAttribute("armorBarColour");
            saveSettings.WriteString(armorBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("sizeBarColour");
            saveSettings.WriteString(sizeBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("hullBarColour");
            saveSettings.WriteString(hullBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("totalSpaceBrushColour");
            saveSettings.WriteString(totalSpaceBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("usedSpaceBrushColour");
            saveSettings.WriteString(usedSpaceBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("notEnoughSpaceBrushColour");
            saveSettings.WriteString(notEnoughSpaceBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("shieldBarColour");
            saveSettings.WriteString(shieldBrush.Color.Name.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up "customColours"

            saveSettings.WriteStartElement("dynamicRedraw");
            saveSettings.WriteStartAttribute("dynamicRedrawDisabled");
            saveSettings.WriteString(screenRedrawCheckBox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up "dynamicRedraw"

            saveSettings.WriteStartElement("windowResize");
            saveSettings.WriteStartAttribute("allowWindowResize");
            saveSettings.WriteString(resizingCheckbox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up

            saveSettings.WriteStartElement("update");
            saveSettings.WriteStartAttribute("onStartup");
            saveSettings.WriteString(updatesCheckbox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up

            saveSettings.WriteStartElement("antiAlias");
            saveSettings.WriteStartAttribute("disabled");
            saveSettings.WriteString(disablePieChartAACheckBox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up

            saveSettings.WriteStartElement("universe");
            saveSettings.WriteStartAttribute("uni");
            saveSettings.WriteString(universeSelectComboBox.Text);
            saveSettings.WriteEndAttribute();
            saveSettings.WriteStartAttribute("autoLoadUniData");
            saveSettings.WriteString(loadUniverseOnStartupCheckbox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up

            saveSettings.WriteStartElement("shipPreview");
            saveSettings.WriteStartAttribute("disableStars");
            saveSettings.WriteString(disableShipPreviewStarsCheckBox.CheckState.ToString());
            saveSettings.WriteEndAttribute();
            saveSettings.WriteEndElement(); // close up

            saveSettings.WriteEndElement(); // close up root.
            saveSettings.WriteEndDocument();
            saveSettings.Close();
        }


        private void LoadSettingsFromXmlFile()
        {
            if (startup != true)
            {
                DialogResult savesettingsDialogResult = MessageBox.Show("Loading Saved Settings: Doing this will overwrite the previously saved setup, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (savesettingsDialogResult == DialogResult.Yes)
                {
                    doXmlLoad();
                }

            }
            else
            {
                doXmlLoad();
            }
        }

        private void doXmlLoad()
        {
            if (Directory.Exists(tameDirectory))
            {
                if (File.Exists(settingsFile))
                {
                    XmlTextReader loadSettings = new XmlTextReader(settingsFile);

                    while (loadSettings.Read())
                    {
                        if (loadSettings.NodeType == XmlNodeType.Element)
                        {

                            if (loadSettings.Name == "customIPSettings")
                            {

                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {

                                    customIPCheckBox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {

                                    customIPCheckBox.CheckState = CheckState.Checked;
                                }

                                imagePackPath = loadSettings.GetAttribute(1);
                                if (imagePackPath != null)
                                {
                                    usingXMLimpackPath = true;
                                    shipImageBox.ImageLocation = ConstructShipImagePaths();
                                }
                                impackURLmodified = bool.Parse(loadSettings.GetAttribute(2));

                            }
                            if (loadSettings.Name == "customColours")
                            {
                                try
                                {
                                    if ((loadSettings.GetAttribute(0).StartsWith("ff")))
                                    {
                                        armorBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(0)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        armorBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(0));
                                    }
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 1 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(1).StartsWith("ff")))
                                    {
                                        sizeBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(1)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        sizeBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(1));
                                    }
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 2 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(2).StartsWith("ff")))
                                    {
                                        hullBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(2)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        hullBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(2));
                                    }
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 3 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(3).StartsWith("ff")))
                                    {
                                        totalSpaceBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(3)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        totalSpaceBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(3));
                                    }

                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 4 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(4).StartsWith("ff")))
                                    {
                                        usedSpaceBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(4)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        usedSpaceBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(4));
                                    }
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 5 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(5).StartsWith("ff")))
                                    {
                                        notEnoughSpaceBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(5)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        notEnoughSpaceBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(5));
                                    }
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 6 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                try
                                {
                                    if ((loadSettings.GetAttribute(6).StartsWith("ff")))
                                    {
                                        shieldBrush.Color = System.Drawing.ColorTranslator.FromHtml("#" + (loadSettings.GetAttribute(6)).Remove(0, 2));
                                    }
                                    else
                                    {
                                        shieldBrush.Color = System.Drawing.Color.FromName(loadSettings.GetAttribute(6));
                                    }

                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Colour Import 7 Failed. You'll probably have to manually reset them from the \"options\" tab. Try contacting Pigeon", "Colour Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }

                            if (loadSettings.Name == "dynamicRedraw")
                            {

                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {
                                    screenRedrawCheckBox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {

                                    screenRedrawCheckBox.CheckState = CheckState.Checked;
                                }
                            }
                            if (loadSettings.Name == "windowResize")
                            {

                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {
                                    resizingCheckbox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {
                                    resizingCheckbox.CheckState = CheckState.Checked;
                                }
                            }
                            if (loadSettings.Name == "update")
                            {

                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {
                                    updatesCheckbox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {
                                    updatesCheckbox.CheckState = CheckState.Checked;
                                }
                            }
                            if (loadSettings.Name == "antiAlias")
                            {
                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {
                                    disablePieChartAACheckBox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {
                                    disablePieChartAACheckBox.CheckState = CheckState.Checked;
                                }
                            }
                            if (loadSettings.Name == "universe")
                            {
                                if (loadSettings.GetAttribute(0) == "Orion")
                                {
                                    universeSelectComboBox.Text = "Orion";
                                }
                                if (loadSettings.GetAttribute(0) == "Artemis")
                                {
                                    universeSelectComboBox.Text = "Artemis";
                                }
                                if (loadSettings.GetAttribute(0) == "Pegasus")
                                {
                                    universeSelectComboBox.Text = "Pegasus";
                                }
                                try
                                {
                                    if (loadSettings.GetAttribute(1) == "Unchecked")
                                    {
                                        loadUniverseOnStartupCheckbox.CheckState = CheckState.Unchecked;
                                    }
                                }
                                catch (Exception) { }
                            }
                            if (loadSettings.Name == "shipPreview")
                            {
                                if (loadSettings.GetAttribute(0) == "Unchecked")
                                {
                                    disableShipPreviewStarsCheckBox.CheckState = CheckState.Unchecked;
                                }
                                else
                                {
                                    disableShipPreviewStarsCheckBox.CheckState = CheckState.Checked;
                                }
                            }
                        }
                    }
                    loadSettings.Close();

                }

                else
                {
                    if (startup != true)
                    {
                        MessageBox.Show(string.Format("{0} could not be found. Does a previous save file exist?", settingsFile), "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    }
                }
            }
            else
            {
                if (startup != true)
                {
                    MessageBox.Show("Directory could not be found. Does it exist?", "Directory Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

        }

        private void loadCustomSettingsButton_Click(object sender, EventArgs e)
        {
            LoadSettingsFromXmlFile();
        }

        private void deletePilotButton_Click(object sender, EventArgs e)
        {
            DialogResult deletePilotDialogResult = MessageBox.Show("Deleting Saved Pilot: Doing this will permanently delete any previously saved setup, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deletePilotDialogResult == DialogResult.Yes)
            {
                if (Directory.Exists(tameDirectory))
                {
                    if (File.Exists(pilotFile))
                    {
                        File.Delete(pilotFile);
                    }
                }
                updateUsedDiskSpace();
            }
        }

        private void savePilotButton_Click(object sender, EventArgs e)
        {
            string faction = "neu";
            string syndicate = "neu";

            DialogResult pilotDialogResult = MessageBox.Show("Saving Pilot: Doing this will overwrite the previously saved setup, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (pilotDialogResult == DialogResult.Yes)
            {
                unsavedChanges = false;
                if (Directory.Exists(tameDirectory) != true)
                {
                    Directory.CreateDirectory(tameDirectory);
                }
                XmlTextWriter savePilot = new XmlTextWriter(pilotFile, null);
                savePilot.WriteStartDocument();
                savePilot.WriteComment("Tame Ship Calc: Auto-Generated XML File. This file holds the user's pilot data settings from the \"pilot\" tab");
                savePilot.WriteStartElement("Root");

                savePilot.WriteStartElement("pilotBio", "");
                savePilot.WriteStartAttribute("male");
                if (maleRadioButton.Checked == true)
                {
                    savePilot.WriteString("checked");
                }
                else
                {
                    savePilot.WriteString("unchecked");
                }
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("race");
                savePilot.WriteString(raceSelectBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("name");
                savePilot.WriteString(pilotNameTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("faction");
                if (fedRadioButton.Checked == true)
                {
                    faction = "fed";
                }
                if (empRadioButton.Checked == true)
                {
                    faction = "emp";
                }
                if (uniRadioButton.Checked == true)
                {
                    faction = "uni";
                }
                if (neuRadioButton.Checked == true)
                {
                    faction = "neu";
                }
                savePilot.WriteString(faction);
                savePilot.WriteEndAttribute();

                savePilot.WriteStartAttribute("syndicate");
                if (epsRadioButton.Checked == true)
                {
                    syndicate = "eps";
                }
                if (tssRadioButton.Checked == true)
                {
                    syndicate = "tss";
                }
                savePilot.WriteString(syndicate);
                savePilot.WriteEndAttribute();
                savePilot.WriteEndElement(); // close up "pilotBio"

                savePilot.WriteStartElement("advancedSkills", "");
                savePilot.WriteStartAttribute("convWeapSpec");
                savePilot.WriteString(cWeapSpecLevelComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("orgWeapSpec");
                savePilot.WriteString(orgWeapSpecComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("emWeapSpec");
                savePilot.WriteString(emWeapSpecComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("defensiveCombat");
                savePilot.WriteString(defensiveCombatComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("offensiveCombat");
                savePilot.WriteString(offensiveCombatComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("agiBoost");
                savePilot.WriteString(agiBoostComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("cloakBoost");
                savePilot.WriteString(cloakingBoostComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("hullFort");
                savePilot.WriteString(hullFortComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("shieldPowering");
                savePilot.WriteString(shieldPoweringComboBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteEndElement(); // close up "advancedSkills"

                savePilot.WriteStartElement("baseSkills", "");
                savePilot.WriteStartAttribute("astMining");
                savePilot.WriteString(baseASTTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("energyCol");
                savePilot.WriteString(baseENETextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("nebCol");
                savePilot.WriteString(baseNEBTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("fuelCol");
                savePilot.WriteString(baseFUETextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("tac");
                savePilot.WriteString(baseTACTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("ha");
                savePilot.WriteString(baseHATextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("man");
                savePilot.WriteString(baseMANTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("weap");
                savePilot.WriteString(baseWEAPTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("eng");
                savePilot.WriteString(baseENGTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("cloak");
                savePilot.WriteString(baseCLOTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteStartAttribute("hack");
                savePilot.WriteString(baseHACKTextBox.Text);
                savePilot.WriteEndAttribute();
                savePilot.WriteEndElement(); // Close up base skills.

                savePilot.WriteEndElement(); // close up root.
                savePilot.WriteEndDocument();
                savePilot.Close();
            }
            updateUsedDiskSpace();
        }

        private void loadPilotButton_Click(object sender, EventArgs e)
        {
            if (startup == true)
            {
                loadPilotFromXML();
            }
            else
            {
                DialogResult pilotDialogResult = MessageBox.Show("Loading Pilot: Doing this will overwrite the pilot you have right now, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (pilotDialogResult == DialogResult.Yes)
                {
                    loadPilotFromXML();
                }
            }
        }

        private void loadPilotFromXML()
        {
            if (Directory.Exists(tameDirectory))
            {
                if (File.Exists(pilotFile))
                {
                    XmlTextReader loadPilot = new XmlTextReader(pilotFile);

                    while (loadPilot.Read())
                    {
                        if (loadPilot.NodeType == XmlNodeType.Element)
                        {

                            if (loadPilot.Name == "pilotBio")
                            {

                                if (loadPilot.GetAttribute(0) == "checked")
                                {
                                    maleRadioButton.Checked = true;
                                }
                                else
                                {
                                    femaleRadioButton.Checked = true;
                                }

                                raceSelectBox.Text = loadPilot.GetAttribute(1);
                                pilotNameTextBox.Text = loadPilot.GetAttribute(2);

                                switch (loadPilot.GetAttribute(3))
                                {
                                    case "fed":
                                        fedRadioButton.Checked = true;
                                        break;

                                    case "emp":
                                        empRadioButton.Checked = true;
                                        break;

                                    case "uni":
                                        uniRadioButton.Checked = true;
                                        break;

                                    case "neu":
                                        neuRadioButton.Checked = true;
                                        break;
                                }
                                switch (loadPilot.GetAttribute(4))
                                {
                                    case "eps":
                                        epsRadioButton.Checked = true;
                                        break;

                                    case "tss":
                                        tssRadioButton.Checked = true;
                                        break;

                                    case "neu":
                                        neuSyndRadioButton.Checked = true;
                                        break;
                                }
                            }
                            if (loadPilot.Name == "advancedSkills")
                            {
                                cWeapSpecLevelComboBox.Text = loadPilot.GetAttribute(0);
                                orgWeapSpecComboBox.Text = loadPilot.GetAttribute(1);
                                emWeapSpecComboBox.Text = loadPilot.GetAttribute(2);
                                defensiveCombatComboBox.Text = loadPilot.GetAttribute(3);
                                offensiveCombatComboBox.Text = loadPilot.GetAttribute(4);
                                agiBoostComboBox.Text = loadPilot.GetAttribute(5);
                                cloakingBoostComboBox.Text = loadPilot.GetAttribute(6);
                                hullFortComboBox.Text = loadPilot.GetAttribute(7);
                                shieldPoweringComboBox.Text = loadPilot.GetAttribute(8);
                            }
                            if (loadPilot.Name == "baseSkills")
                            {
                                baseASTTextBox.Text = loadPilot.GetAttribute(0);
                                baseENETextBox.Text = loadPilot.GetAttribute(1);
                                baseNEBTextBox.Text = loadPilot.GetAttribute(2);
                                baseFUETextBox.Text = loadPilot.GetAttribute(3);
                                baseTACTextBox.Text = loadPilot.GetAttribute(4);
                                baseHATextBox.Text = loadPilot.GetAttribute(5);
                                baseMANTextBox.Text = loadPilot.GetAttribute(6);
                                baseWEAPTextBox.Text = loadPilot.GetAttribute(7);
                                baseENGTextBox.Text = loadPilot.GetAttribute(8);
                                baseCLOTextBox.Text = loadPilot.GetAttribute(9);
                                baseHACKTextBox.Text = loadPilot.GetAttribute(10);
                            }
                        }
                    }
                    refreshPilotTabSkills();
                }
                else
                {
                    if (startup != true)
                    {
                        MessageBox.Show(string.Format("{0} could not be found. Does a previous save file exist?", pilotFile), "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        private void CheckForUpdates(bool quiet)
        {
            if (quiet == true)
            {
                updateCheck uc = new updateCheck(quiet, statusStrip1);
            }
            else
            {
                UpdateChecker loadingForm = new UpdateChecker();
                loadingForm.ShowDialog();
                loadingForm.Close();
            }
        }
        #endregion

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (unsavedChanges == true)
            {
                shutdown = true;
                DialogResult unsavedChangesDialogResult = MessageBox.Show("You have made some changes since you last saved, do you wish to save the changes?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (unsavedChangesDialogResult == DialogResult.Yes)
                {
                    saveSettingsButton_Click(sender, e);
                    saveLoadoutButton_Click(sender, e);
                }
            }
        }


        #region pictureBoxClicking

        private void hullBarArrorPictureBox_MouseClick(object sender, MouseEventArgs e)
        {

        }

        private void armorBarArrorPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveArmorLabel.Visible != true)
            {
                shipArmorPanel.Visible = false;
                effectiveArmorLabel.Visible = true;
            }
            else
            {
                shipArmorPanel.Visible = true;
                effectiveArmorLabel.Visible = false;
            }
        }

        private void armorBarRightArrowPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveArmorLabel.Visible != true)
            {
                shipArmorPanel.Visible = false;
                effectiveArmorLabel.Visible = true;
            }
            else
            {
                shipArmorPanel.Visible = true;
                effectiveArmorLabel.Visible = false;
            }
        }

        private void hullBarLeftArrowPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveHullLabel.Visible != true)
            {
                shipHullPanel.Visible = false;
                effectiveHullLabel.Visible = true;
            }
            else
            {
                shipHullPanel.Visible = true;
                effectiveHullLabel.Visible = false;
            }
        }

        private void hullBarRightArrowPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveHullLabel.Visible != true)
            {
                shipHullPanel.Visible = false;
                effectiveHullLabel.Visible = true;
            }
            else
            {
                shipHullPanel.Visible = true;
                effectiveHullLabel.Visible = false;
            }
        }

        private void shieldBarLeftArrowPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveShieldLabel.Visible != true)
            {
                shipShieldPanel.Visible = false;
                effectiveShieldLabel.Visible = true;
            }
            else
            {
                shipShieldPanel.Visible = true;
                effectiveShieldLabel.Visible = false;
            }
        }

        private void shieldArrowRightPictureBox_Click(object sender, EventArgs e)
        {
            if (effectiveShieldLabel.Visible != true)
            {
                shipShieldPanel.Visible = false;
                effectiveShieldLabel.Visible = true;
            }
            else
            {
                shipShieldPanel.Visible = true;
                effectiveShieldLabel.Visible = false;
            }
        }
        #endregion


        private void updatesCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
        }
        #endregion//Out of the way for now.

        #region MissileSelection

        private void EnableorDisableMissileBoxes(ref int missileMounts)
        {
            #region 0
            if (missileMounts == 0)
            {
                missileLoadoutComboBox1.Text = "";
                missileLoadoutComboBox1.Enabled = false;

                missileLoadoutComboBox2.Text = "";
                missileLoadoutComboBox2.Enabled = false;

                missileLoadoutComboBox3.Text = "";
                missileLoadoutComboBox3.Enabled = false;

                missileLoadoutComboBox4.Text = "";
                missileLoadoutComboBox4.Enabled = false;

                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox5.Enabled = false;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;

            }
            #endregion
            #region 1
            if (missileMounts == 1)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Text = "";
                missileLoadoutComboBox2.Enabled = false;

                missileLoadoutComboBox3.Text = "";
                missileLoadoutComboBox3.Enabled = false;

                missileLoadoutComboBox4.Text = "";
                missileLoadoutComboBox4.Enabled = false;

                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox5.Enabled = false;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 2
            if (missileMounts == 2)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Text = "";
                missileLoadoutComboBox3.Enabled = false;

                missileLoadoutComboBox4.Text = "";
                missileLoadoutComboBox4.Enabled = false;

                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox5.Enabled = false;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;

            }
            #endregion
            #region 3
            if (missileMounts == 3)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Text = "";
                missileLoadoutComboBox4.Enabled = false;

                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox5.Enabled = false;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;

            }
            #endregion
            #region 4
            if (missileMounts == 4)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox5.Enabled = false;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 5
            if (missileMounts == 5)
            {

                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox6.Enabled = false;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 6
            if (missileMounts == 6)
            {

                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox7.Enabled = false;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 7
            if (missileMounts == 7)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox8.Enabled = false;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 8
            if (missileMounts == 8)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox9.Enabled = false;

                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox10.Enabled = false;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 10
            if (missileMounts == 10)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Enabled = true;

                missileLoadoutComboBox10.Enabled = true;

                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox11.Enabled = false;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 11
            if (missileMounts == 11)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Enabled = true;

                missileLoadoutComboBox10.Enabled = true;

                missileLoadoutComboBox11.Enabled = true;

                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox12.Enabled = false;

                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox13.Enabled = false;

                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox14.Enabled = false;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 14
            if (missileMounts == 14)
            {

                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Enabled = true;

                missileLoadoutComboBox10.Enabled = true;

                missileLoadoutComboBox11.Enabled = true;

                missileLoadoutComboBox12.Enabled = true;

                missileLoadoutComboBox13.Enabled = true;

                missileLoadoutComboBox14.Enabled = true;

                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox15.Enabled = false;

                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox16.Enabled = false;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 16
            if (missileMounts == 16)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Enabled = true;

                missileLoadoutComboBox10.Enabled = true;

                missileLoadoutComboBox11.Enabled = true;

                missileLoadoutComboBox12.Enabled = true;

                missileLoadoutComboBox13.Enabled = true;

                missileLoadoutComboBox14.Enabled = true;

                missileLoadoutComboBox15.Enabled = true;

                missileLoadoutComboBox16.Enabled = true;

                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox17.Enabled = false;

                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox18.Enabled = false;

                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox19.Enabled = false;

                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox20.Enabled = false;

                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox21.Enabled = false;

                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox22.Enabled = false;

                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox23.Enabled = false;

                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox24.Enabled = false;

                missileLoadoutComboBox25.Text = "";
                missileLoadoutComboBox25.Enabled = false;
            }
            #endregion
            #region 25
            if (missileMounts == 25)
            {
                missileLoadoutComboBox1.Enabled = true;

                missileLoadoutComboBox2.Enabled = true;

                missileLoadoutComboBox3.Enabled = true;

                missileLoadoutComboBox4.Enabled = true;

                missileLoadoutComboBox5.Enabled = true;

                missileLoadoutComboBox6.Enabled = true;

                missileLoadoutComboBox7.Enabled = true;

                missileLoadoutComboBox8.Enabled = true;

                missileLoadoutComboBox9.Enabled = true;

                missileLoadoutComboBox10.Enabled = true;

                missileLoadoutComboBox11.Enabled = true;

                missileLoadoutComboBox12.Enabled = true;

                missileLoadoutComboBox13.Enabled = true;

                missileLoadoutComboBox14.Enabled = true;

                missileLoadoutComboBox15.Enabled = true;

                missileLoadoutComboBox16.Enabled = true;

                missileLoadoutComboBox17.Enabled = true;

                missileLoadoutComboBox18.Enabled = true;

                missileLoadoutComboBox19.Enabled = true;

                missileLoadoutComboBox20.Enabled = true;

                missileLoadoutComboBox21.Enabled = true;

                missileLoadoutComboBox22.Enabled = true;

                missileLoadoutComboBox23.Enabled = true;

                missileLoadoutComboBox24.Enabled = true;

                missileLoadoutComboBox25.Enabled = true;
            }
            #endregion
        }

        // Quick Missiles copies a set number of missiles onto the designer.
        // #FIXME Using the DialogResult is a bit of a hack. Needs changing.
        private void commonLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DialogResult missiles = DialogResult.Cancel;

            missileAmounts missileAmounts = new missileAmounts();
            missileAmounts.ShowDialog();
            missiles = missileAmounts.DialogResult;

            if (missiles != DialogResult.Cancel)
            {
                missileLoadoutComboBox2.Text = "";
                missileLoadoutComboBox3.Text = "";
                missileLoadoutComboBox4.Text = "";
                missileLoadoutComboBox5.Text = "";
                missileLoadoutComboBox6.Text = "";
                missileLoadoutComboBox7.Text = "";
                missileLoadoutComboBox8.Text = "";
                missileLoadoutComboBox9.Text = "";
                missileLoadoutComboBox10.Text = "";
                missileLoadoutComboBox11.Text = "";
                missileLoadoutComboBox12.Text = "";
                missileLoadoutComboBox13.Text = "";
                missileLoadoutComboBox14.Text = "";
                missileLoadoutComboBox15.Text = "";
                missileLoadoutComboBox16.Text = "";
                missileLoadoutComboBox17.Text = "";
                missileLoadoutComboBox18.Text = "";
                missileLoadoutComboBox19.Text = "";
                missileLoadoutComboBox20.Text = "";
                missileLoadoutComboBox21.Text = "";
                missileLoadoutComboBox22.Text = "";
                missileLoadoutComboBox23.Text = "";
                missileLoadoutComboBox24.Text = "";
                missileLoadoutComboBox25.Text = "";
            }

            if (missiles == DialogResult.Ignore)
            {
                if (missileLoadoutComboBox2.Enabled == true)
                {
                    missileLoadoutComboBox2.Text = missileLoadoutComboBox1.Text;
                }
            }
            if (missiles == DialogResult.Abort)
            {
                if (missileLoadoutComboBox2.Enabled == true)
                {
                    missileLoadoutComboBox2.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox3.Enabled == true)
                {
                    missileLoadoutComboBox3.Text = missileLoadoutComboBox1.Text;
                }
            }
            if (missiles == DialogResult.No)
            {
                if (missileLoadoutComboBox2.Enabled == true)
                {
                    missileLoadoutComboBox2.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox3.Enabled == true)
                {
                    missileLoadoutComboBox3.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox4.Enabled == true)
                {
                    missileLoadoutComboBox4.Text = missileLoadoutComboBox1.Text;
                }
            }
            if (missiles == DialogResult.OK)
            {
                if (missileLoadoutComboBox2.Enabled == true)
                {
                    missileLoadoutComboBox2.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox3.Enabled == true)
                {
                    missileLoadoutComboBox3.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox4.Enabled == true)
                {
                    missileLoadoutComboBox4.Text = missileLoadoutComboBox1.Text;
                }
                if (missileLoadoutComboBox5.Enabled == true)
                {
                    missileLoadoutComboBox5.Text = missileLoadoutComboBox1.Text;
                }
            }
        }

        private void missileLoadoutComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox1.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox1.Name.ToString();

                missileDamageLabel1.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel1.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel1.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel1.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel1.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox1.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox1, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox1.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox1, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox1.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox1.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox2.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox2.Name.ToString();

                missileDamageLabel2.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel2.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel2.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel2.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel2.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox2.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox2, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox2.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox2, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox2.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox2.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox3.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox3.Name.ToString();

                missileDamageLabel3.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel3.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel3.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel3.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel3.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox3.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox3, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox3.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox3, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox3.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox3.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox4.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox4.Name.ToString();

                missileDamageLabel4.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel4.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel4.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel4.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel4.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox4.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox4, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox4.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox4, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox4.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox4.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {

            unsavedChanges = true;
            if (missileLoadoutComboBox5.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox5.Name.ToString();

                missileDamageLabel5.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel5.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel5.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel5.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel5.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox5.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox5, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox5.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox5, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox5.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox5.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox6.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox6.Name.ToString();

                missileDamageLabel6.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel6.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel6.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel6.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel6.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox6.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox6, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox6.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox6, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox6.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox6.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox7.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox7.Name.ToString();

                missileDamageLabel7.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel7.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel7.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel7.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel7.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox7.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox7, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox7.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox7, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox7.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox7.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox8.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox8.Name.ToString();

                missileDamageLabel8.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel8.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel8.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel8.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel8.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox8.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox8, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox8.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox8, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox8.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox8.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox9_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox9.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox9.Name.ToString();

                missileDamageLabel9.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel9.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel9.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel9.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel9.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox9.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox9, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox9.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox9, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox9.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox9.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox10_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox10.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox10.Name.ToString();

                missileDamageLabel10.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel10.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel10.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel10.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel10.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox10.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox10, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox10.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox10, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox10.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox10.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox11_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox11.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox11.Name.ToString();

                missileDamageLabel11.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel11.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel11.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel11.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel11.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox11.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox11, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox11.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox11, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox11.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox11.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox12_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox12.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox12.Name.ToString();

                missileDamageLabel12.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel12.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel12.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel12.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel12.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox12.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox12, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox12.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox12, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox12.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox12.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox13_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox13.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox13.Name.ToString();

                missileDamageLabel13.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel13.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel13.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel13.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel13.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox13.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox13, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox13.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox13, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox13.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox13.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox14_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox14.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox14.Name.ToString();

                missileDamageLabel14.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel14.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel14.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel14.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel14.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox14.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox14, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox14.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox14, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox14.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox14.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox15_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox15.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox15.Name.ToString();

                missileDamageLabel15.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel15.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel15.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel15.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel15.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox15.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox15, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox15.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox15, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox15.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox15.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox16_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox16.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox16.Name.ToString();

                missileDamageLabel16.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel16.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel16.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel16.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel16.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox16.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox16, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox16.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox16, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox16.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox16.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox17_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox17.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox17.Name.ToString();

                missileDamageLabel17.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel17.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel17.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel17.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel17.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox17.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox17, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox17.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox17, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox17.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox17.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox18_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox18.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox18.Name.ToString();

                missileDamageLabel18.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel18.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel18.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel18.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel18.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox18.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox18, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox18.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox18, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox18.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox18.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox19_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox19.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox19.Name.ToString();

                missileDamageLabel19.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel19.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel19.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel19.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel19.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox19.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox19, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox19.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox19, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox19.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox19.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox20_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox20.Enabled == true)
            {
                // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox20.Name.ToString();

                missileDamageLabel20.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel20.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel20.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel20.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel20.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString(missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox20.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox20, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox20.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox20, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox20.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox20.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox21_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox21.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox21.Name.ToString();

                missileDamageLabel21.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel21.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel21.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel21.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel21.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox21.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox21, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox21.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox21, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox21.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox21.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox22_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox22.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox22.Name.ToString();

                missileDamageLabel22.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel22.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel22.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel22.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel22.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox22.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox22, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox22.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox22, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox22.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox22.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox23_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox23.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox23.Name.ToString();

                missileDamageLabel23.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel23.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel23.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel23.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel23.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox23.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox23, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox23.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox23, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox23.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox23.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox24_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox24.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox24.Name.ToString();

                missileDamageLabel24.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel24.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel24.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel24.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel24.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox24.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox24, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox24.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox24, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox24.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox24.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private void missileLoadoutComboBox25_SelectedIndexChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
            if (missileLoadoutComboBox25.Enabled == true)
            {
                int modeDamage = 0;
                int modeIntelligence = 1;
                int modeWeight = 2;
                int modeART = 3;
                int modeCost = 4;
                int modeRank = 5;

                int missileRankRequirement = 0;

                string imagePackPath = GetImagePackPath();
                string comboBoxName = missileLoadoutComboBox25.Name.ToString();

                missileDamageLabel25.Text = GetMissileData(ref modeDamage, ref comboBoxName).ToString("N0");
                missileIntLabel25.Text = GetMissileData(ref modeIntelligence, ref comboBoxName).ToString();
                missileWeightLabel25.Text = GetMissileData(ref modeWeight, ref comboBoxName).ToString();
                missileARTLabel25.Text = GetMissileData(ref modeART, ref comboBoxName).ToString();
                missileCostLabel25.Text = GetMissileData(ref modeCost, ref comboBoxName).ToString("N0");
                missileRankRequirement = GetMissileData(ref modeRank, ref comboBoxName);

                if (missileRankRequirement > 0)
                {
                    // Add rank image:
                    string rankImageURL = "";
                    string rankName = "";
                    rankName = rankData.ParseRankIDToString( missileRankRequirement);
                    rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                    rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                    missileRankImageBox25.ImageLocation = rankImageURL;
                    toolTip1.SetToolTip(this.missileRankImageBox25, rankData.ParseRankIDToString( missileRankRequirement));
                }
                else
                {
                    missileRankImageBox25.ImageLocation = null;
                    toolTip1.SetToolTip(this.missileRankImageBox25, null);
                }

                // Add equipment image
                string missileImageURL = "";
                missileImageURL = imagePackHandler.ConvertEquipmentNameToImagePath(missileLoadoutComboBox25.Text);
                missileImageURL = Path.Combine(imagePackPath, missileImageURL);
                missilePictureBox25.ImageLocation = missileImageURL;


                // Redraw used space.
                int modeHullCapacity = 2;
                int shipHullCapacity = playerShip.GetShipData(ref modeHullCapacity, shipSelectBox.Text);
                DrawStandardShipUsedSpaceBar(ref shipHullCapacity);
                shipHullCapacity = shipHullCapacity / 2;

                // Check for rank conflicts
                CheckForRankRequirementConflicts();

                // Update totals labels:
                totalMissileWeightLabel.Text = aggregateMissileWeight().ToString();
                totalMissileCostLabel.Text = aggregateMissileCost().ToString("N0");
                totalMissileDamageLabel.Text = aggregateMissileDamage().ToString("N0");

                //Update Summary Page:
                updateSummaryPage();
            }
        }

        private int aggregateMissileWeight()
        {
            // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
            int modeWeight = 2;
            int totalMissileWeight;

            string missile1 = missileLoadoutComboBox1.Name.ToString();
            string missile2 = missileLoadoutComboBox2.Name.ToString();
            string missile3 = missileLoadoutComboBox3.Name.ToString();
            string missile4 = missileLoadoutComboBox4.Name.ToString();
            string missile5 = missileLoadoutComboBox5.Name.ToString();
            string missile6 = missileLoadoutComboBox6.Name.ToString();
            string missile7 = missileLoadoutComboBox7.Name.ToString();
            string missile8 = missileLoadoutComboBox8.Name.ToString();
            string missile9 = missileLoadoutComboBox9.Name.ToString();
            string missile10 = missileLoadoutComboBox10.Name.ToString();
            string missile11 = missileLoadoutComboBox11.Name.ToString();
            string missile12 = missileLoadoutComboBox12.Name.ToString();
            string missile13 = missileLoadoutComboBox13.Name.ToString();
            string missile14 = missileLoadoutComboBox14.Name.ToString();
            string missile15 = missileLoadoutComboBox15.Name.ToString();
            string missile16 = missileLoadoutComboBox16.Name.ToString();
            string missile17 = missileLoadoutComboBox17.Name.ToString();
            string missile18 = missileLoadoutComboBox18.Name.ToString();
            string missile19 = missileLoadoutComboBox19.Name.ToString();
            string missile20 = missileLoadoutComboBox20.Name.ToString();
            string missile21 = missileLoadoutComboBox21.Name.ToString();
            string missile22 = missileLoadoutComboBox22.Name.ToString();
            string missile23 = missileLoadoutComboBox23.Name.ToString();
            string missile24 = missileLoadoutComboBox24.Name.ToString();
            string missile25 = missileLoadoutComboBox25.Name.ToString();

            int missileRequirement1 = GetMissileData(ref modeWeight, ref missile1);
            int missileRequirement2 = GetMissileData(ref modeWeight, ref missile2);
            int missileRequirement3 = GetMissileData(ref modeWeight, ref missile3);
            int missileRequirement4 = GetMissileData(ref modeWeight, ref missile4);
            int missileRequirement5 = GetMissileData(ref modeWeight, ref missile5);
            int missileRequirement6 = GetMissileData(ref modeWeight, ref missile6);
            int missileRequirement7 = GetMissileData(ref modeWeight, ref missile7);
            int missileRequirement8 = GetMissileData(ref modeWeight, ref missile8);
            int missileRequirement9 = GetMissileData(ref modeWeight, ref missile9);
            int missileRequirement10 = GetMissileData(ref modeWeight, ref missile10);
            int missileRequirement11 = GetMissileData(ref modeWeight, ref missile11);
            int missileRequirement12 = GetMissileData(ref modeWeight, ref missile12);
            int missileRequirement13 = GetMissileData(ref modeWeight, ref missile13);
            int missileRequirement14 = GetMissileData(ref modeWeight, ref missile14);
            int missileRequirement15 = GetMissileData(ref modeWeight, ref missile15);
            int missileRequirement16 = GetMissileData(ref modeWeight, ref missile16);
            int missileRequirement17 = GetMissileData(ref modeWeight, ref missile17);
            int missileRequirement18 = GetMissileData(ref modeWeight, ref missile18);
            int missileRequirement19 = GetMissileData(ref modeWeight, ref missile19);
            int missileRequirement20 = GetMissileData(ref modeWeight, ref missile20);
            int missileRequirement21 = GetMissileData(ref modeWeight, ref missile21);
            int missileRequirement22 = GetMissileData(ref modeWeight, ref missile22);
            int missileRequirement23 = GetMissileData(ref modeWeight, ref missile23);
            int missileRequirement24 = GetMissileData(ref modeWeight, ref missile24);
            int missileRequirement25 = GetMissileData(ref modeWeight, ref missile25);

            totalMissileWeight = (missileRequirement1 + missileRequirement2 + missileRequirement3 + missileRequirement4 + missileRequirement5 + missileRequirement6 + missileRequirement7 + missileRequirement8 + missileRequirement9 +
                missileRequirement10 + missileRequirement11 + missileRequirement12 + missileRequirement13 + missileRequirement14 + missileRequirement15 + missileRequirement16 + missileRequirement17 + missileRequirement18 +
                missileRequirement19 + missileRequirement20 + missileRequirement21 + missileRequirement22 + missileRequirement23 + missileRequirement24 + missileRequirement25);

            return totalMissileWeight;
        }

        private int aggregateMissileCost()
        {
            // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
            int modeCost = 4;
            int totalMissileCost;

            string missile1 = missileLoadoutComboBox1.Name.ToString();
            string missile2 = missileLoadoutComboBox2.Name.ToString();
            string missile3 = missileLoadoutComboBox3.Name.ToString();
            string missile4 = missileLoadoutComboBox4.Name.ToString();
            string missile5 = missileLoadoutComboBox5.Name.ToString();
            string missile6 = missileLoadoutComboBox6.Name.ToString();
            string missile7 = missileLoadoutComboBox7.Name.ToString();
            string missile8 = missileLoadoutComboBox8.Name.ToString();
            string missile9 = missileLoadoutComboBox9.Name.ToString();
            string missile10 = missileLoadoutComboBox10.Name.ToString();
            string missile11 = missileLoadoutComboBox11.Name.ToString();
            string missile12 = missileLoadoutComboBox12.Name.ToString();
            string missile13 = missileLoadoutComboBox13.Name.ToString();
            string missile14 = missileLoadoutComboBox14.Name.ToString();
            string missile15 = missileLoadoutComboBox15.Name.ToString();
            string missile16 = missileLoadoutComboBox16.Name.ToString();
            string missile17 = missileLoadoutComboBox17.Name.ToString();
            string missile18 = missileLoadoutComboBox18.Name.ToString();
            string missile19 = missileLoadoutComboBox19.Name.ToString();
            string missile20 = missileLoadoutComboBox20.Name.ToString();
            string missile21 = missileLoadoutComboBox21.Name.ToString();
            string missile22 = missileLoadoutComboBox22.Name.ToString();
            string missile23 = missileLoadoutComboBox23.Name.ToString();
            string missile24 = missileLoadoutComboBox24.Name.ToString();
            string missile25 = missileLoadoutComboBox25.Name.ToString();

            int missileRequirement1 = GetMissileData(ref modeCost, ref missile1);
            int missileRequirement2 = GetMissileData(ref modeCost, ref missile2);
            int missileRequirement3 = GetMissileData(ref modeCost, ref missile3);
            int missileRequirement4 = GetMissileData(ref modeCost, ref missile4);
            int missileRequirement5 = GetMissileData(ref modeCost, ref missile5);
            int missileRequirement6 = GetMissileData(ref modeCost, ref missile6);
            int missileRequirement7 = GetMissileData(ref modeCost, ref missile7);
            int missileRequirement8 = GetMissileData(ref modeCost, ref missile8);
            int missileRequirement9 = GetMissileData(ref modeCost, ref missile9);
            int missileRequirement10 = GetMissileData(ref modeCost, ref missile10);
            int missileRequirement11 = GetMissileData(ref modeCost, ref missile11);
            int missileRequirement12 = GetMissileData(ref modeCost, ref missile12);
            int missileRequirement13 = GetMissileData(ref modeCost, ref missile13);
            int missileRequirement14 = GetMissileData(ref modeCost, ref missile14);
            int missileRequirement15 = GetMissileData(ref modeCost, ref missile15);
            int missileRequirement16 = GetMissileData(ref modeCost, ref missile16);
            int missileRequirement17 = GetMissileData(ref modeCost, ref missile17);
            int missileRequirement18 = GetMissileData(ref modeCost, ref missile18);
            int missileRequirement19 = GetMissileData(ref modeCost, ref missile19);
            int missileRequirement20 = GetMissileData(ref modeCost, ref missile20);
            int missileRequirement21 = GetMissileData(ref modeCost, ref missile21);
            int missileRequirement22 = GetMissileData(ref modeCost, ref missile22);
            int missileRequirement23 = GetMissileData(ref modeCost, ref missile23);
            int missileRequirement24 = GetMissileData(ref modeCost, ref missile24);
            int missileRequirement25 = GetMissileData(ref modeCost, ref missile25);

            totalMissileCost = (missileRequirement1 + missileRequirement2 + missileRequirement3 + missileRequirement4 + missileRequirement5 + missileRequirement6 + missileRequirement7 + missileRequirement8 + missileRequirement9 +
                missileRequirement10 + missileRequirement11 + missileRequirement12 + missileRequirement13 + missileRequirement14 + missileRequirement15 + missileRequirement16 + missileRequirement17 + missileRequirement18 +
                missileRequirement19 + missileRequirement20 + missileRequirement21 + missileRequirement22 + missileRequirement23 + missileRequirement24 + missileRequirement25);

            return totalMissileCost;
        }

        private int aggregateMissileDamage()
        {
            // Format: {0: damage, 1: intelligence, 2: mass, 3: art, 4: cost, 5: rank}
            int modeDamage = 0;
            int totalMissileDamage;

            string missile1 = missileLoadoutComboBox1.Name.ToString();
            string missile2 = missileLoadoutComboBox2.Name.ToString();
            string missile3 = missileLoadoutComboBox3.Name.ToString();
            string missile4 = missileLoadoutComboBox4.Name.ToString();
            string missile5 = missileLoadoutComboBox5.Name.ToString();
            string missile6 = missileLoadoutComboBox6.Name.ToString();
            string missile7 = missileLoadoutComboBox7.Name.ToString();
            string missile8 = missileLoadoutComboBox8.Name.ToString();
            string missile9 = missileLoadoutComboBox9.Name.ToString();
            string missile10 = missileLoadoutComboBox10.Name.ToString();
            string missile11 = missileLoadoutComboBox11.Name.ToString();
            string missile12 = missileLoadoutComboBox12.Name.ToString();
            string missile13 = missileLoadoutComboBox13.Name.ToString();
            string missile14 = missileLoadoutComboBox14.Name.ToString();
            string missile15 = missileLoadoutComboBox15.Name.ToString();
            string missile16 = missileLoadoutComboBox16.Name.ToString();
            string missile17 = missileLoadoutComboBox17.Name.ToString();
            string missile18 = missileLoadoutComboBox18.Name.ToString();
            string missile19 = missileLoadoutComboBox19.Name.ToString();
            string missile20 = missileLoadoutComboBox20.Name.ToString();
            string missile21 = missileLoadoutComboBox21.Name.ToString();
            string missile22 = missileLoadoutComboBox22.Name.ToString();
            string missile23 = missileLoadoutComboBox23.Name.ToString();
            string missile24 = missileLoadoutComboBox24.Name.ToString();
            string missile25 = missileLoadoutComboBox25.Name.ToString();

            int missileRequirement1 = GetMissileData(ref modeDamage, ref missile1);
            int missileRequirement2 = GetMissileData(ref modeDamage, ref missile2);
            int missileRequirement3 = GetMissileData(ref modeDamage, ref missile3);
            int missileRequirement4 = GetMissileData(ref modeDamage, ref missile4);
            int missileRequirement5 = GetMissileData(ref modeDamage, ref missile5);
            int missileRequirement6 = GetMissileData(ref modeDamage, ref missile6);
            int missileRequirement7 = GetMissileData(ref modeDamage, ref missile7);
            int missileRequirement8 = GetMissileData(ref modeDamage, ref missile8);
            int missileRequirement9 = GetMissileData(ref modeDamage, ref missile9);
            int missileRequirement10 = GetMissileData(ref modeDamage, ref missile10);
            int missileRequirement11 = GetMissileData(ref modeDamage, ref missile11);
            int missileRequirement12 = GetMissileData(ref modeDamage, ref missile12);
            int missileRequirement13 = GetMissileData(ref modeDamage, ref missile13);
            int missileRequirement14 = GetMissileData(ref modeDamage, ref missile14);
            int missileRequirement15 = GetMissileData(ref modeDamage, ref missile15);
            int missileRequirement16 = GetMissileData(ref modeDamage, ref missile16);
            int missileRequirement17 = GetMissileData(ref modeDamage, ref missile17);
            int missileRequirement18 = GetMissileData(ref modeDamage, ref missile18);
            int missileRequirement19 = GetMissileData(ref modeDamage, ref missile19);
            int missileRequirement20 = GetMissileData(ref modeDamage, ref missile20);
            int missileRequirement21 = GetMissileData(ref modeDamage, ref missile21);
            int missileRequirement22 = GetMissileData(ref modeDamage, ref missile22);
            int missileRequirement23 = GetMissileData(ref modeDamage, ref missile23);
            int missileRequirement24 = GetMissileData(ref modeDamage, ref missile24);
            int missileRequirement25 = GetMissileData(ref modeDamage, ref missile25);

            totalMissileDamage = (missileRequirement1 + missileRequirement2 + missileRequirement3 + missileRequirement4 + missileRequirement5 + missileRequirement6 + missileRequirement7 + missileRequirement8 + missileRequirement9 +
                missileRequirement10 + missileRequirement11 + missileRequirement12 + missileRequirement13 + missileRequirement14 + missileRequirement15 + missileRequirement16 + missileRequirement17 + missileRequirement18 +
                missileRequirement19 + missileRequirement20 + missileRequirement21 + missileRequirement22 + missileRequirement23 + missileRequirement24 + missileRequirement25);

            return totalMissileDamage;
        }

        #endregion

        #region missile copy labels
        private void missileCopyLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox2.Enabled == true)
            {
                missileLoadoutComboBox2.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox3.Enabled == true)
            {
                missileLoadoutComboBox3.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox4.Enabled == true)
            {
                missileLoadoutComboBox4.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox5.Enabled == true)
            {
                missileLoadoutComboBox5.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox6.Enabled == true)
            {
                missileLoadoutComboBox6.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox1.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox1.Text;
            }

        }

        private void missileCopyLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox3.Enabled == true)
            {
                missileLoadoutComboBox3.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox4.Enabled == true)
            {
                missileLoadoutComboBox4.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox5.Enabled == true)
            {
                missileLoadoutComboBox5.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox6.Enabled == true)
            {
                missileLoadoutComboBox6.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox2.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox2.Text;
            }
        }

        private void missileCopyLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox4.Enabled == true)
            {
                missileLoadoutComboBox4.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox5.Enabled == true)
            {
                missileLoadoutComboBox5.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox6.Enabled == true)
            {
                missileLoadoutComboBox6.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox3.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox3.Text;
            }
        }

        private void missileCopyLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox5.Enabled == true)
            {
                missileLoadoutComboBox5.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox6.Enabled == true)
            {
                missileLoadoutComboBox6.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox4.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox4.Text;
            }
        }

        private void missileCopyLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox6.Enabled == true)
            {
                missileLoadoutComboBox6.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox5.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox5.Text;
            }
        }

        private void missileCopyLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox7.Enabled == true)
            {
                missileLoadoutComboBox7.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox6.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox6.Text;
            }
        }

        private void missileCopyLabel7_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox8.Enabled == true)
            {
                missileLoadoutComboBox8.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox7.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox7.Text;
            }
        }

        private void missileCopyLabel8_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox9.Enabled == true)
            {
                missileLoadoutComboBox9.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox8.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox8.Text;
            }
        }

        private void missileCopyLabel9_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox10.Enabled == true)
            {
                missileLoadoutComboBox10.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox9.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox9.Text;
            }
        }

        private void missileCopyLabel10_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox11.Enabled == true)
            {
                missileLoadoutComboBox11.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox10.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox10.Text;
            }
        }

        private void missileCopyLabel11_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox12.Enabled == true)
            {
                missileLoadoutComboBox12.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox11.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox11.Text;
            }

        }

        private void missileCopyLabel12_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox13.Enabled == true)
            {
                missileLoadoutComboBox13.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox12.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox12.Text;
            }
        }

        private void missileCopyLabel13_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox14.Enabled == true)
            {
                missileLoadoutComboBox14.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox13.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox13.Text;
            }
        }

        private void missileCopyLabel14_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox15.Enabled == true)
            {
                missileLoadoutComboBox15.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox14.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox14.Text;
            }
        }

        private void missileCopyLabel15_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox16.Enabled == true)
            {
                missileLoadoutComboBox16.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox15.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox15.Text;
            }
        }

        private void missileCopyLabel16_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox17.Enabled == true)
            {
                missileLoadoutComboBox17.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox16.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox16.Text;
            }
        }

        private void missileCopyLabel17_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox18.Enabled == true)
            {
                missileLoadoutComboBox18.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox17.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox17.Text;
            }
        }

        private void missileCopyLabel18_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox19.Enabled == true)
            {
                missileLoadoutComboBox19.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox18.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox18.Text;
            }
        }

        private void missileCopyLabel19_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox20.Enabled == true)
            {
                missileLoadoutComboBox20.Text = missileLoadoutComboBox19.Text;
            }
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox19.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox19.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox19.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox19.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox19.Text;
            }
        }

        private void missileCopyLabel20_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox21.Enabled == true)
            {
                missileLoadoutComboBox21.Text = missileLoadoutComboBox20.Text;
            }
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox20.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox20.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox20.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox20.Text;
            }
        }

        private void missileCopyLabel21_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox22.Enabled == true)
            {
                missileLoadoutComboBox22.Text = missileLoadoutComboBox21.Text;
            }
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox21.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox21.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox21.Text;
            }
        }

        private void missileCopyLabel22_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox23.Enabled == true)
            {
                missileLoadoutComboBox23.Text = missileLoadoutComboBox22.Text;
            }
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox22.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox22.Text;
            }
        }

        private void missileCopyLabel23_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox24.Enabled == true)
            {
                missileLoadoutComboBox24.Text = missileLoadoutComboBox23.Text;
            }
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox23.Text;
            }
        }

        private void linkLabel24_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (missileLoadoutComboBox25.Enabled == true)
            {
                missileLoadoutComboBox25.Text = missileLoadoutComboBox24.Text;
            }
        }
        #endregion

        #region Reset boxes
        private void driveClearPictureBox_Click(object sender, EventArgs e)
        {
            driveSelectBox.Text = "";
        }

        private void shieldClearPictureBox_Click(object sender, EventArgs e)
        {
            shieldSelectComboBox.Text = "";
        }

        private void armorClearPictureBox_Click(object sender, EventArgs e)
        {
            armorComboBox.Text = "";
        }

        private void missileClearPictureBox_Click(object sender, EventArgs e)
        {
            missileLoadoutComboBox1.Text = "";
            missileLoadoutComboBox2.Text = "";
            missileLoadoutComboBox3.Text = "";
            missileLoadoutComboBox4.Text = "";
            missileLoadoutComboBox5.Text = "";
            missileLoadoutComboBox6.Text = "";
            missileLoadoutComboBox7.Text = "";
            missileLoadoutComboBox8.Text = "";
            missileLoadoutComboBox9.Text = "";
            missileLoadoutComboBox10.Text = "";
            missileLoadoutComboBox11.Text = "";
            missileLoadoutComboBox12.Text = "";
            missileLoadoutComboBox13.Text = "";
            missileLoadoutComboBox14.Text = "";
            missileLoadoutComboBox15.Text = "";
            missileLoadoutComboBox16.Text = "";
            missileLoadoutComboBox17.Text = "";
            missileLoadoutComboBox18.Text = "";
            missileLoadoutComboBox19.Text = "";
            missileLoadoutComboBox20.Text = "";
            missileLoadoutComboBox21.Text = "";
            missileLoadoutComboBox22.Text = "";
            missileLoadoutComboBox23.Text = "";
            missileLoadoutComboBox24.Text = "";
            missileLoadoutComboBox25.Text = "";
        }

        private void specialClearPictureBox_Click(object sender, EventArgs e)
        {
            autoRefuelerCheckBox.Checked = false;
            escapePodCheckBox.Checked = false;
            fuelScoopCheckBox.Checked = false;
            bussardRamscoopCheckBox.Checked = false;
            magScoopCheckBox.Checked = false;
            ambushTeleporterCheckBox.Checked = false;
            eccmJammerCheckBox.Checked = false;
            keyOfSheppardCheckBox.Checked = false;
            epsContrabandScannerCheckBox.Checked = false;
            epsContrabandDroneCheckBox.Checked = false;
            bodypartMaskerCheckBox.Checked = false;

            teleporterComboBox.Text = ":: No Teleporter ::";
            mapPackComboBox.Text = ":: No Map Pack ::";
            bountyLinkComboBox.Text = ":: No Bounty Link ::";
            gyroStabiliserComboBox.Text = ":: No Gyro ::";
            ecmJammerSelectBox.Text = ":: No Jammer ::";
            fluxCapacitorSelectBox.Text = ":: No Capacitor ::";
            cloakerSelectBox.Text = ":: No Cloaker ::";
            interferometerSelectBox.Text = ":: No Interferometer ::";
            dampingFieldSelectBox.Text = ":: No Damping Field ::";
            dematSelectBox.Text = ":: No Dematerializer ::";
        }

        private void masterResetPictureBox_Click(object sender, EventArgs e)
        {
            DialogResult saveDialogResult = MessageBox.Show("You're about to reset the designer, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (saveDialogResult == DialogResult.Yes)
            {
                gunPageClearPictureBox_Click(sender, e);
                shieldClearPictureBox_Click(sender, e);
                driveClearPictureBox_Click(sender, e);
                armorClearPictureBox_Click(sender, e);
                missileClearPictureBox_Click(sender, e);
                specialClearPictureBox_Click(sender, e);
            }
        }

        #endregion

        #region specialequipment
        private int calculateTotalSpecialWeight()
        {
            int[,] tempSpecialData = SpecialData();
            int weight;
            int totalWeight = 0;

            // CheckBoxes
            if (autoRefuelerCheckBox.Checked == true)
            {
                weight = tempSpecialData[0, 0];
                totalWeight = totalWeight + weight;
            }
            if (escapePodCheckBox.Checked == true)
            {
                weight = tempSpecialData[1, 0];
                totalWeight = totalWeight + weight;
            }
            if (fuelScoopCheckBox.Checked == true)
            {
                weight = tempSpecialData[2, 0];
                totalWeight = totalWeight + weight;
            }
            if (bussardRamscoopCheckBox.Checked == true)
            {
                weight = tempSpecialData[3, 0];
                totalWeight = totalWeight + weight;
            }
            if (magScoopCheckBox.Checked == true)
            {
                weight = tempSpecialData[4, 0];
                totalWeight = totalWeight + weight;
            }
            if (ambushTeleporterCheckBox.Checked == true)
            {
                weight = tempSpecialData[5, 0];
                totalWeight = totalWeight + weight;
            }

            // ComboBoxes
            if (teleporterComboBox.Text == "Class I Teleporter")
            {
                weight = tempSpecialData[6, 0];
                totalWeight = totalWeight + weight;

            }
            if (teleporterComboBox.Text == "Class II Teleporter")
            {
                weight = tempSpecialData[7, 0];
                totalWeight = totalWeight + weight;
            }
            // No need for SU: Maps, Bounty, Gyros - as they have no weight.
            //Sensitive
            if (ecmJammerSelectBox.Text == "ECM Jammer")
            {
                weight = tempSpecialData[15, 0];
                totalWeight = totalWeight + weight;
            }
            if (ecmJammerSelectBox.Text == "Strong ECM Jammer")
            {
                weight = tempSpecialData[16, 0];
                totalWeight = totalWeight + weight;
            }
            if (eccmJammerCheckBox.Checked == true)
            {
                weight = tempSpecialData[17, 0];
                totalWeight = totalWeight + weight;
            }
            if (fluxCapacitorSelectBox.Text == "Weak Gas Flux Capacitor")
            {
                weight = tempSpecialData[18, 0];
                totalWeight = totalWeight + weight;
            }
            if (fluxCapacitorSelectBox.Text == "Weak Energy Flux Capacitor")
            {
                weight = tempSpecialData[19, 0];
                totalWeight = totalWeight + weight;
            }
            if (fluxCapacitorSelectBox.Text == "Strong Gas Flux Capacitor")
            {
                weight = tempSpecialData[20, 0];
                totalWeight = totalWeight + weight;
            }
            if (fluxCapacitorSelectBox.Text == "Strong Energy Flux Capacitor")
            {
                weight = tempSpecialData[21, 0];
                totalWeight = totalWeight + weight;
            }
            if (keyOfSheppardCheckBox.Checked == true)
            {
                weight = tempSpecialData[22, 0];
                totalWeight = totalWeight + weight;
            }
            if (epsContrabandScannerCheckBox.Checked == true)
            {
                weight = tempSpecialData[23, 0];
                totalWeight = totalWeight + weight;
            }
            if (cloakerSelectBox.Text == "Cloaking Device")
            {
                weight = tempSpecialData[24, 0];
                totalWeight = totalWeight + weight;
            }
            if (cloakerSelectBox.Text == "Improved Cloaking Device")
            {
                weight = tempSpecialData[25, 0];
                totalWeight = totalWeight + weight;
            }
            if (interferometerSelectBox.Text == "Single-Wave Interferometer")
            {
                weight = tempSpecialData[26, 0];
                totalWeight = totalWeight + weight;
            }
            if (interferometerSelectBox.Text == "Dual-Wave Interferometer")
            {
                weight = tempSpecialData[27, 0];
                totalWeight = totalWeight + weight;
            }
            if (interferometerSelectBox.Text == "Triple-Wave Interferometer")
            {
                weight = tempSpecialData[28, 0];
                totalWeight = totalWeight + weight;
            }
            if (dampingFieldSelectBox.Text == "Damping Field Generator")
            {
                weight = tempSpecialData[29, 0];
                totalWeight = totalWeight + weight;
            }
            if (dampingFieldSelectBox.Text == "Reinforced Damping Field Generator")
            {
                weight = tempSpecialData[30, 0];
                totalWeight = totalWeight + weight;
            }
            if (dampingFieldSelectBox.Text == "Perfected Damping Field Generator")
            {
                weight = tempSpecialData[31, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Light Dematerializer Mk.I")
            {
                weight = tempSpecialData[32, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.I")
            {
                weight = tempSpecialData[33, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.I")
            {
                weight = tempSpecialData[34, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Light Dematerializer Mk.II")
            {
                weight = tempSpecialData[35, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.II")
            {
                weight = tempSpecialData[36, 0];
                totalWeight = totalWeight + weight;
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.II")
            {
                weight = tempSpecialData[37, 0];
                totalWeight = totalWeight + weight;
            }
            if (epsContrabandDroneCheckBox.Checked == true)
            {
                totalWeight += tempSpecialData[38, 0];
            }

            totalSpecialWeightLabel.Text = totalWeight.ToString() + " T.";

            return totalWeight;
        }

        private int calculateTotalSpecialCost()
        {
            int[,] tempSpecialData = SpecialData();
            int cost;
            int totalCost = 0;

            // CheckBoxes
            if (autoRefuelerCheckBox.Checked == true)
            {
                cost = tempSpecialData[0, 1];
                totalCost = totalCost + cost;
            }
            if (escapePodCheckBox.Checked == true)
            {
                cost = tempSpecialData[1, 1];
                totalCost = totalCost + cost;
            }
            if (fuelScoopCheckBox.Checked == true)
            {
                cost = tempSpecialData[2, 1];
                totalCost = totalCost + cost;
            }
            if (bussardRamscoopCheckBox.Checked == true)
            {
                cost = tempSpecialData[3, 1];
                totalCost = totalCost + cost;
            }
            if (magScoopCheckBox.Checked == true)
            {
                cost = tempSpecialData[4, 1];
                totalCost = totalCost + cost;
            }
            if (ambushTeleporterCheckBox.Checked == true)
            {
                cost = tempSpecialData[5, 1];
                totalCost = totalCost + cost;
            }

            // ComboBoxes
            if (teleporterComboBox.Text == "Class I Teleporter")
            {
                cost = tempSpecialData[6, 1];
                totalCost = totalCost + cost;
            }
            if (teleporterComboBox.Text == "Class II Teleporter")
            {
                cost = tempSpecialData[7, 1];
                totalCost = totalCost + cost;
            }
            if (mapPackComboBox.Text == "Map Pack I")
            {
                cost = tempSpecialData[8, 1];
                totalCost = totalCost + cost;
            }
            if (mapPackComboBox.Text == "Map Pack II")
            {
                cost = tempSpecialData[9, 1];
                totalCost = totalCost + cost;
            }
            if (bountyLinkComboBox.Text == "Bounty Link I")
            {
                cost = tempSpecialData[10, 1];
                totalCost = totalCost + cost;
            }
            if (bountyLinkComboBox.Text == "Bounty Link II")
            {
                cost = tempSpecialData[11, 1];
                totalCost = totalCost + cost;
            }
            if (bountyLinkComboBox.Text == "Bounty Link III")
            {
                cost = tempSpecialData[12, 1];
                totalCost = totalCost + cost;
            }
            if (gyroStabiliserComboBox.Text == "Gyro Stabilizer I")
            {
                cost = tempSpecialData[13, 1];
                totalCost = totalCost + cost;
            }
            if (gyroStabiliserComboBox.Text == "Gyro Stabilizer II")
            {
                cost = tempSpecialData[14, 1];
                totalCost = totalCost + cost;
            }

            //Sensitive
            if (ecmJammerSelectBox.Text == "ECM Jammer")
            {
                cost = tempSpecialData[15, 1];
                totalCost = totalCost + cost;
            }
            if (ecmJammerSelectBox.Text == "Strong ECM Jammer")
            {
                cost = tempSpecialData[16, 1];
                totalCost = totalCost + cost;
            }
            if (eccmJammerCheckBox.Checked == true)
            {
                cost = tempSpecialData[17, 0];
                totalCost = totalCost + cost;
            }
            if (fluxCapacitorSelectBox.Text == "Weak Gas Flux Capacitor")
            {
                cost = tempSpecialData[18, 1];
                totalCost = totalCost + cost;
            }
            if (fluxCapacitorSelectBox.Text == "Weak Energy Flux Capacitor")
            {
                cost = tempSpecialData[19, 1];
                totalCost = totalCost + cost;
            }
            if (fluxCapacitorSelectBox.Text == "Strong Gas Flux Capacitor")
            {
                cost = tempSpecialData[20, 1];
                totalCost = totalCost + cost;
            }
            if (fluxCapacitorSelectBox.Text == "Strong Energy Flux Capacitor")
            {
                cost = tempSpecialData[21, 1];
                totalCost = totalCost + cost;
            }
            if (keyOfSheppardCheckBox.Checked == true)
            {
                cost = tempSpecialData[22, 1];
                totalCost = totalCost + cost;
            }
            if (epsContrabandScannerCheckBox.Checked == true)
            {
                cost = tempSpecialData[23, 1];
                totalCost = totalCost + cost;
            }
            if (cloakerSelectBox.Text == "Cloaking Device")
            {
                cost = tempSpecialData[24, 1];
                totalCost = totalCost + cost;
            }
            if (cloakerSelectBox.Text == "Improved Cloaking Device")
            {
                cost = tempSpecialData[25, 1];
                totalCost = totalCost + cost;
            }
            if (interferometerSelectBox.Text == "Single-Wave Interferometer")
            {
                cost = tempSpecialData[26, 1];
                totalCost = totalCost + cost;
            }
            if (interferometerSelectBox.Text == "Dual-Wave Interferometer")
            {
                cost = tempSpecialData[27, 1];
                totalCost = totalCost + cost;
            }
            if (interferometerSelectBox.Text == "Triple-Wave Interferometer")
            {
                cost = tempSpecialData[28, 1];
                totalCost = totalCost + cost;
            }
            if (dampingFieldSelectBox.Text == "Damping Field Generator")
            {
                cost = tempSpecialData[29, 1];
                totalCost = totalCost + cost;
            }
            if (dampingFieldSelectBox.Text == "Reinforced Damping Field Generator")
            {
                cost = tempSpecialData[30, 1];
                totalCost = totalCost + cost;
            }
            if (dampingFieldSelectBox.Text == "Perfected Damping Field Generator")
            {
                cost = tempSpecialData[31, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Light Dematerializer Mk.I")
            {
                cost = tempSpecialData[32, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.I")
            {
                cost = tempSpecialData[33, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.I")
            {
                cost = tempSpecialData[34, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Light Dematerializer Mk.II")
            {
                cost = tempSpecialData[35, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.II")
            {
                cost = tempSpecialData[36, 1];
                totalCost = totalCost + cost;
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.II")
            {
                cost = tempSpecialData[37, 1];
                totalCost = totalCost + cost;
            }
            if (epsContrabandDroneCheckBox.Checked == true)
            {
                cost = tempSpecialData[38, 1];
                totalCost = totalCost + cost;
            }
            if (bodypartMaskerCheckBox.Checked == true)
            {
                totalCost += tempSpecialData[39, 1];
            }

            totalSpecialCostLabel.Text = totalCost.ToString("N0");

            return totalCost;
        }

        private void autoRefuellerCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[0, 0];
            int cost = tempSpecialData[0, 1];

            if (autoRefuelerCheckBox.Checked == true)
            {
                autoRefuelerCostLabel.Text = string.Format("{0:N0}", cost);
                autoRefuelerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "auto_refueler.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                autoRefuelerPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.autoRefuellerInfoBox, "Automatially refills your fuel tank, using" + Environment.NewLine + "hydrogen fuel from your cargo hold.");
            }
            else
            {
                autoRefuelerCostLabel.Text = "0";
                autoRefuelerWeightLabel.Text = "0";
                autoRefuelerPictureBox.ImageLocation = null;
                // Change Tooltip:
                toolTip1.SetToolTip(this.autoRefuellerInfoBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();

            //Update Summary Page:
            updateSummaryPage();
            CheckForRankRequirementConflicts();
        }

        private void escapePodCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[1, 0];
            int cost = tempSpecialData[1, 1];

            if (escapePodCheckBox.Checked == true)
            {
                escapePodCostLabel.Text = string.Format("{0:N0}", cost);
                escapePodWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "escape_pod.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                escapePodPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.escapePodInfoBox, "1. Saves crew on death (non-legendary)." + Environment.NewLine + "2. Prevents random equipment loss." + Environment.NewLine + "3. Prevents 24hr skill penalty. (cloning)." + Environment.NewLine + "");
            }
            else
            {
                escapePodCostLabel.Text = "0";
                escapePodWeightLabel.Text = "0";
                escapePodPictureBox.ImageLocation = null;
                // Change Tooltip:
                toolTip1.SetToolTip(this.escapePodInfoBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void fuelScoopCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[2, 0];
            int cost = tempSpecialData[2, 1];

            if (fuelScoopCheckBox.Checked == true)
            {
                fuelScoopCostLabel.Text = string.Format("{0:N0}", cost);
                fuelScoopWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "fuel_scoop.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                fuelScoopPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.fuelScoopInfoBox, "Allows you to harvest hydrogen from space tiles.");
            }
            else
            {
                fuelScoopCostLabel.Text = "0";
                fuelScoopWeightLabel.Text = "0";
                fuelScoopPictureBox.ImageLocation = null;

                // Change Tooltip:
                toolTip1.SetToolTip(this.fuelScoopInfoBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void bussardRamscoopCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[3, 0];
            int cost = tempSpecialData[3, 1];

            if (bussardRamscoopCheckBox.Checked == true)
            {
                bussardCostLabel.Text = string.Format("{0:N0}", cost);
                bussardWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "bussard_ramscoop.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                bussardPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.bussardInfoBox, "Automatically harvests up to 5t of fuel if they have > 150 and you have < 10t on board." + Environment.NewLine + " Costs 1AP per T of fuel (can cause -ve aps)");

            }
            else
            {
                bussardCostLabel.Text = "0";
                bussardWeightLabel.Text = "0";
                bussardPictureBox.ImageLocation = null;

                // Change Tooltip:
                toolTip1.SetToolTip(this.bussardInfoBox, null);

            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void magScoopCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[4, 0];
            int cost = tempSpecialData[4, 1];

            if (magScoopCheckBox.Checked == true)
            {
                magScoopCostLabel.Text = string.Format("{0:N0}", cost);
                magScoopWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "magnetic_scoop.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                magScoopPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.magscoopInfoBox, "Increases ccargo capacity by 150t, with higher movement" + Environment.NewLine + "cost and lower maneuver skill when holding cargo");

            }
            else
            {
                magScoopCostLabel.Text = "0";
                magScoopWeightLabel.Text = "0";
                magScoopPictureBox.ImageLocation = null;

                // Change Tooltip:
                toolTip1.SetToolTip(this.magscoopInfoBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void ambushTeleporterCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();
            int weight = tempSpecialData[5, 0];
            int cost = tempSpecialData[5, 1];

            if (ambushTeleporterCheckBox.Checked == true)
            {
                ambushTeleporterCostLabel.Text = string.Format("{0:N0}", cost);
                ambushTeleporterWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "ambush_teleporter.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                ambushTeleporterPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.ambushTeleporterInfoBox, "Needed for setting and using ambush retreat points.");
            }
            else
            {
                ambushTeleporterCostLabel.Text = "0";
                ambushTeleporterWeightLabel.Text = "0";
                ambushTeleporterPictureBox.ImageLocation = null;
                // Change Tooltip:
                toolTip1.SetToolTip(this.ambushTeleporterInfoBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void teleporterComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((teleporterComboBox.Text == ":: No Teleporter ::") || (teleporterComboBox.Text == ""))
            {
                teleporterCostLabel.Text = "0";
                teleporterWeightLabel.Text = "0";
                teleporterPictureBox.ImageLocation = null;
                toolTip1.SetToolTip(this.telePorterInfoBox, null);
                teleporterRequirementsImageBox.Image = null;
                toolTip1.SetToolTip(this.teleporterRequirementsImageBox, "Rank required for Tele.");
            }
            if (teleporterComboBox.Text == "Class I Teleporter")
            {
                int weight = tempSpecialData[6, 0];
                int cost = tempSpecialData[6, 1];
                teleporterRequirementsImageBox.Image = null;
                toolTip1.SetToolTip(this.teleporterRequirementsImageBox, "No Requirement");

                teleporterCostLabel.Text = string.Format("{0:N0}", cost);
                teleporterWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "teleporter_1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                teleporterPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.telePorterInfoBox, "60% Teleporting Success");
            }
            if (teleporterComboBox.Text == "Class II Teleporter")
            {
                int weight = tempSpecialData[7, 0];
                int cost = tempSpecialData[7, 1];

                teleporterRequirementsImageBox.Image = Tame.Properties.Resources.xp_icon;
                toolTip1.SetToolTip(this.teleporterRequirementsImageBox, "100XP Required");

                teleporterCostLabel.Text = string.Format("{0:N0}", cost);
                teleporterWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "teleporter_2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                teleporterPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.telePorterInfoBox, "75% Teleporting Success." + Environment.NewLine + "Better Telerobbing, Equal trading.");
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void mapPackComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((mapPackComboBox.Text == ":: No Map Pack ::") || (mapPackComboBox.Text == ":: None ::"))
            {
                mapPackCostLabel.Text = "0";
                mapPackPictureBox.ImageLocation = null;
                toolTip1.SetToolTip(this.mapPackInfoBox, null);
            }
            if (mapPackComboBox.Text == "Map Pack I")
            {
                int cost = tempSpecialData[8, 1];

                mapPackCostLabel.Text = string.Format("{0:N0}", cost);

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "mappack_1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                mapPackPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.mapPackInfoBox, "Shows sectors in overview screen, and gains access" + Environment.NewLine + "to the building indices of these surrounding sectors");
            }
            if (mapPackComboBox.Text == "Map Pack II")
            {
                int cost = tempSpecialData[9, 1];

                mapPackCostLabel.Text = string.Format("{0:N0}", cost);

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "mappack_2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                mapPackPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.mapPackInfoBox, "Shows sectors and wormholes in overview screen," + Environment.NewLine + "and gains access to the building indices of these surrounding sectors");
            }
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void bountyLinkComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*Parse Error: Invalid "fed bounty" parameter in Quicklist! Option not available without bounty link II or III! */
            int[,] tempSpecialData = SpecialData();

            if ((bountyLinkComboBox.Text == ":: No Bounty Link ::") || (bountyLinkComboBox.Text == ""))
            {
                bountyLinkCostLabel.Text = "0";
                bountyLinkPictureBox.ImageLocation = null;
                toolTip1.SetToolTip(this.bountyLinkInfoBox, null);
                bountyLinkRequirements.Image = null;
                toolTip1.SetToolTip(this.bountyLinkRequirements, "Rank required for Bounty Link.");
            }
            if (bountyLinkComboBox.Text == "Bounty Link I")
            {
                int cost = tempSpecialData[10, 1];

                bountyLinkCostLabel.Text = string.Format("{0:N0}", cost);
                bountyLinkRequirements.Image = null;
                toolTip1.SetToolTip(this.bountyLinkRequirements, "Rank required for Bounty Link.");

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "bountylink_1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                bountyLinkPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.bountyLinkInfoBox, "Shows players with bounties");
            }
            if (bountyLinkComboBox.Text == "Bounty Link II")
            {
                int cost = tempSpecialData[11, 1];

                bountyLinkRequirements.Image = Tame.Properties.Resources.xp_icon;
                toolTip1.SetToolTip(this.bountyLinkRequirements, "1000XP Required");

                bountyLinkCostLabel.Text = string.Format("{0:N0}", cost);

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "bountylink_2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                bountyLinkPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.bountyLinkInfoBox, "Shows players with bounties and kill bounty reward." + Environment.NewLine + "Allows ambushing for bounties");
            }
            if (bountyLinkComboBox.Text == "Bounty Link III")
            {
                int cost = tempSpecialData[12, 1];

                bountyLinkCostLabel.Text = string.Format("{0:N0}", cost);

                bountyLinkRequirements.Image = Tame.Properties.Resources.xp_icon;
                toolTip1.SetToolTip(this.bountyLinkRequirements, "3250XP Required");

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "bountylink_3.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                bountyLinkPictureBox.ImageLocation = equipmentImageURL;

                // Change Tooltip:
                toolTip1.SetToolTip(this.bountyLinkInfoBox, "Shows players with bounties and kill/destroy bounty reward." + Environment.NewLine + "Allows ambushing for bounties");
            }
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            //Update Summary Page:
            updateSummaryPage();
        }

        private void gyroStabiliserComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((gyroStabiliserComboBox.Text == ":: No Gyro ::") || (gyroStabiliserComboBox.Text == ""))
            {
                gyroStabiliserPictureBox.ImageLocation = null;
                gyroStabiliserRankPictureBox.ImageLocation = null;
                gyroStabiliserCostLabel.Text = "0";
                gyroStabiliserWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.gyroInfoBox, null);
                toolTip1.SetToolTip(this.gyroStabiliserRankPictureBox, null);
            }
            if (gyroStabiliserComboBox.Text == "Gyro Stabilizer I")
            {
                int cost = tempSpecialData[13, 1];
                int rank = tempSpecialData[13, 2];

                gyroStabiliserCostLabel.Text = string.Format("{0:N0}", cost);

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "gyro_stabilizer_1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                gyroStabiliserPictureBox.ImageLocation = equipmentImageURL;

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( rank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                gyroStabiliserRankPictureBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.gyroStabiliserRankPictureBox, rankName);

                // Change Tooltip:
                toolTip1.SetToolTip(this.gyroInfoBox, "Reduces AP cost for wormhole jumps by 40%" + Environment.NewLine + "(does not affect AP cost for X-hole or Y-hole jumps)");
            }
            if (gyroStabiliserComboBox.Text == "Gyro Stabilizer II")
            {
                int cost = tempSpecialData[14, 1];
                int rank = tempSpecialData[14, 2];

                gyroStabiliserCostLabel.Text = string.Format("{0:N0}", cost);

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "gyro_stabilizer_2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                gyroStabiliserPictureBox.ImageLocation = equipmentImageURL;

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( rank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                gyroStabiliserRankPictureBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.gyroStabiliserRankPictureBox, rankName);

                // Change Tooltip:
                toolTip1.SetToolTip(this.gyroInfoBox, "Reduces AP cost for wormhole jumps by 90%" + Environment.NewLine + "(does not affect AP cost for X-hole or Y-hole jumps)	Mogul (Union)");
            }
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void ecmJammerSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((ecmJammerSelectBox.Text == ":: No Jammer ::") || (ecmJammerSelectBox.Text == ""))
            {
                ecmJammerPictureBox.ImageLocation = null;
                ecmJammerRankImageBox.ImageLocation = null;
                ecmJammerCostLabel.Text = "0";
                ecmJammerWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.ecmInfoBox, null);
                toolTip1.SetToolTip(this.ecmJammerRankImageBox, null);
            }
            if (ecmJammerSelectBox.Text == "ECM Jammer")
            {
                int weight = tempSpecialData[15, 0];
                int cost = tempSpecialData[15, 1];

                ecmJammerCostLabel.Text = string.Format("{0:N0}", cost);
                ecmJammerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "ecm_jammer.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                ecmJammerPictureBox.ImageLocation = equipmentImageURL;

                ecmJammerRankImageBox.ImageLocation = null;

                toolTip1.SetToolTip(this.ecmInfoBox, "Reduces probability of being hit with missiles in combat by 30%");
            }
            if (ecmJammerSelectBox.Text == "Strong ECM Jammer")
            {
                int weight = tempSpecialData[16, 0];
                int cost = tempSpecialData[16, 1];

                ecmJammerCostLabel.Text = string.Format("{0:N0}", cost);
                ecmJammerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "ecm_jammer_strong.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                ecmJammerPictureBox.ImageLocation = equipmentImageURL;

                int ecmRank = tempSpecialData[16, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( ecmRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                ecmJammerRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.ecmJammerRankImageBox, rankName);

                toolTip1.SetToolTip(this.ecmInfoBox, "Reduces probability of being hit with missiles in combat by 40%");
            }
            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void eccmJammerCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if (eccmJammerCheckBox.Checked == true)
            {
                int weight = tempSpecialData[17, 0];
                int cost = tempSpecialData[17, 1];

                eccmJammerCostLabel.Text = string.Format("{0:N0}", cost);
                eccmJammerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "eccm_jammer.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                eccmJammerPictureBox.ImageLocation = equipmentImageURL;

                int eccmRank = tempSpecialData[17, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( eccmRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                eccmJammerRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.eccmJammerRankImageBox, rankName);

                toolTip1.SetToolTip(this.eccmInfoBox, "Nullifies the effect of your opponent's ECM Jammer");

            }
            else
            {
                eccmJammerCostLabel.Text = "0";
                eccmJammerWeightLabel.Text = "0";
                eccmJammerPictureBox.ImageLocation = null;
                eccmJammerRankImageBox.ImageLocation = null;
                toolTip1.SetToolTip(this.eccmInfoBox, null);
                toolTip1.SetToolTip(this.eccmJammerRankImageBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void fluxCapacitorSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((fluxCapacitorSelectBox.Text == ":: No Capacitor ::") || (fluxCapacitorSelectBox.Text == ""))
            {
                fluxCapacitorPictureBox.ImageLocation = null;
                fluxCapacitorRankImageBox.ImageLocation = null;
                fluxCapacitorCostLabel.Text = "0";
                fluxCapacitorWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.fluxCapacitorInfoBox, null);
                toolTip1.SetToolTip(this.fluxCapacitorRankImageBox, null);
            }
            if (fluxCapacitorSelectBox.Text == "Weak Gas Flux Capacitor")
            {
                int weight = tempSpecialData[18, 0];
                int cost = tempSpecialData[18, 1];
                fluxCapacitorCostLabel.Text = string.Format("{0:N0}", cost);
                fluxCapacitorWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "flux_capacitor_gas.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                fluxCapacitorPictureBox.ImageLocation = equipmentImageURL;

                int fluxRank = tempSpecialData[18, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( fluxRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                fluxCapacitorRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.fluxCapacitorRankImageBox, rankName);

                toolTip1.SetToolTip(this.fluxCapacitorInfoBox, "Reduces your ship's movement cost in Nebula by 1 AP");

            }
            if (fluxCapacitorSelectBox.Text == "Weak Energy Flux Capacitor")
            {
                int weight = tempSpecialData[19, 0];
                int cost = tempSpecialData[19, 1];
                fluxCapacitorCostLabel.Text = string.Format("{0:N0}", cost);
                fluxCapacitorWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "flux_capacitor_energy.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                fluxCapacitorPictureBox.ImageLocation = equipmentImageURL;

                int fluxRank = tempSpecialData[19, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( fluxRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                fluxCapacitorRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.fluxCapacitorRankImageBox, rankName);

                toolTip1.SetToolTip(this.fluxCapacitorInfoBox, "Reduces your ship's movement cost in Energy by 1 AP");
            }
            if (fluxCapacitorSelectBox.Text == "Strong Gas Flux Capacitor")
            {
                int weight = tempSpecialData[20, 0];
                int cost = tempSpecialData[20, 1];
                fluxCapacitorCostLabel.Text = string.Format("{0:N0}", cost);
                fluxCapacitorWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "flux_capacitor_gas_strong.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                fluxCapacitorPictureBox.ImageLocation = equipmentImageURL;

                int fluxRank = tempSpecialData[20, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( fluxRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                fluxCapacitorRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.fluxCapacitorRankImageBox, rankName);

                toolTip1.SetToolTip(this.fluxCapacitorInfoBox, "Reduces your ship's movement cost in Nebula by 2 APs");
            }
            if (fluxCapacitorSelectBox.Text == "Strong Energy Flux Capacitor")
            {
                int weight = tempSpecialData[21, 0];
                int cost = tempSpecialData[21, 1];
                fluxCapacitorCostLabel.Text = string.Format("{0:N0}", cost);
                fluxCapacitorWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "flux_capacitor_energy_strong.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                fluxCapacitorPictureBox.ImageLocation = equipmentImageURL;

                int fluxRank = tempSpecialData[21, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( fluxRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                fluxCapacitorRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.fluxCapacitorRankImageBox, rankName);

                toolTip1.SetToolTip(this.fluxCapacitorInfoBox, "Reduces your ship's movement cost in Energy by 2 APs");
            }
            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();
            determineMovementCost();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void keyOfSheppardCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();


            if (keyOfSheppardCheckBox.Checked == true)
            {

                int weight = tempSpecialData[22, 0];
                int cost = tempSpecialData[22, 1];

                keyOfSheppardCostLabel.Text = string.Format("{0:N0}", cost);
                keyOfSheppardWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "key_of_sheppard.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                keyOfSheppardPictureBox.ImageLocation = equipmentImageURL;

                int kosRank = tempSpecialData[22, 2];

                // Add rank image:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( kosRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                keyOfSheppardRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.keyOfSheppardRankImageBox, rankName);

                toolTip1.SetToolTip(this.keyOfShepparInfoBox, "Allows you to jump through Sheppard Warp Gates.");
            }
            else
            {
                keyOfSheppardCostLabel.Text = "0";
                keyOfSheppardWeightLabel.Text = "0";
                keyOfSheppardPictureBox.ImageLocation = null;
                keyOfSheppardRankImageBox.ImageLocation = null;
                toolTip1.SetToolTip(this.keyOfShepparInfoBox, null);
                toolTip1.SetToolTip(this.keyOfSheppardRankImageBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void contrabandScannerCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if (epsContrabandScannerCheckBox.Checked == true)
            {
                int weight = tempSpecialData[23, 0];
                int cost = tempSpecialData[23, 1];

                epsContrabandScannerCostLabel.Text = string.Format("{0:N0}", cost);
                epsContrabandScannerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "eps_contraband_scanner.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                epsContrabandScannerPictureBox.ImageLocation = equipmentImageURL;


                // Add rank image:
                string rankImageURL = Path.Combine("factions", "sign_eps_16x16.png");
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                epsContrabandScannerRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.epsContrabandScannerRankImageBox, "Requires EPS Membership");

                toolTip1.SetToolTip(this.epsScannerInfoBox, "Scan the cargo of ships for contraband. Results in" + Environment.NewLine + "bounties in faction space.");
            }
            else
            {
                epsContrabandScannerCostLabel.Text = "0";
                epsContrabandScannerWeightLabel.Text = "0";
                epsContrabandScannerPictureBox.ImageLocation = null;
                epsContrabandScannerRankImageBox.ImageLocation = null;
                toolTip1.SetToolTip(this.epsScannerInfoBox, null);
                toolTip1.SetToolTip(this.epsContrabandScannerRankImageBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void epsContrabandDroneCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if (epsContrabandDroneCheckBox.Checked == true)
            {
                int weight = tempSpecialData[38, 0];
                int cost = tempSpecialData[38, 1];

                epsContrabandDroneCostLabel.Text = string.Format("{0:N0}", cost);
                epsContrabandDroneWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "eps_contraband_drone.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                epsContrabandDronePictureBox.ImageLocation = equipmentImageURL;


                // Add rank image:
                string rankImageURL = Path.Combine("factions", "sign_eps_16x16.png");
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                epsContrabandDroneRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.epsContrabandDroneRankImageBox, "Requires EPS Membership");

                toolTip1.SetToolTip(this.epsContrabandDroneInfoBox, "Scan the cargo of ships for contraband remotely. Results in" + Environment.NewLine + "bounties, wormhole damage.");
            }
            else
            {
                epsContrabandDroneCostLabel.Text = "0";
                epsContrabandDroneWeightLabel.Text = "0";
                epsContrabandDronePictureBox.ImageLocation = null;
                epsContrabandDroneRankImageBox.ImageLocation = null;
                toolTip1.SetToolTip(this.epsContrabandDroneInfoBox, null);
                toolTip1.SetToolTip(this.epsContrabandDroneRankImageBox, null);
            }

            calculateTotalSpecialWeight();
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        } 
    

        private void cloakerSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((cloakerSelectBox.Text == ":: No Cloaker ::") || (cloakerSelectBox.Text == ""))
            {
                cloakerPictureBox.ImageLocation = null;
                cloakerTSSRankImageBox.ImageLocation = null;
                cloakerUniRankImageBox.ImageLocation = null;
                cloakerCostLabel.Text = "0";
                cloakingDeviceWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.cloakerInfoBox, null);
                cloakerORLabel.Visible = false;
                toolTip1.SetToolTip(this.cloakerTSSRankImageBox, null);
                toolTip1.SetToolTip(this.cloakerUniRankImageBox, null);
            }
            if (cloakerSelectBox.Text == "Cloaking Device")
            {
                int weight = tempSpecialData[24, 0];
                int cost = tempSpecialData[24, 1];

                cloakerCostLabel.Text = string.Format("{0:N0}", cost);
                cloakingDeviceWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "cloaking_device.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                cloakerPictureBox.ImageLocation = equipmentImageURL;

                int cloakerUniRank = int.Parse(tempSpecialData[24, 2].ToString().Remove(2, 2));
                int cloakerTSSRank = int.Parse(tempSpecialData[24, 2].ToString().Remove(0, 2));

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( cloakerTSSRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                cloakerTSSRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.cloakerTSSRankImageBox, rankName);

                rankName = rankData.ParseRankIDToString( cloakerUniRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                cloakerUniRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.cloakerUniRankImageBox, rankName);

                toolTip1.SetToolTip(this.cloakerInfoBox, "Adds 25 percentage points to the probability to successful cloaking");
                cloakerORLabel.Visible = true;
            }

            if (cloakerSelectBox.Text == "Improved Cloaking Device")
            {
                int weight = tempSpecialData[25, 0];
                int cost = tempSpecialData[25, 1];

                cloakerCostLabel.Text = string.Format("{0:N0}", cost);
                cloakingDeviceWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "cloaking_device_improved.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                cloakerPictureBox.ImageLocation = equipmentImageURL;

                int cloakerRank = tempSpecialData[25, 2];

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( cloakerRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);

                cloakerUniRankImageBox.ImageLocation = null;
                cloakerTSSRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.cloakerTSSRankImageBox, rankName);

                toolTip1.SetToolTip(this.cloakerInfoBox, "Adds 40 percentage points to the probability to successful cloaking.");
                cloakerORLabel.Visible = false;
            }
            calculateTotalSpecialCost();
            calculateTotalSpecialWeight();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void interferometerSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((interferometerSelectBox.Text == ":: No Interferometer ::") || (interferometerSelectBox.Text == ""))
            {
                interferometerPictureBox.ImageLocation = null;
                interferometerTSSRankImageBox.ImageLocation = null;
                interferometerUniRankImageBox.ImageLocation = null;
                interferometerCostLabel.Text = "0";
                interferometerWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.interferometerInfoBox, null);
                interferometerORLabel.Visible = false;
                toolTip1.SetToolTip(this.interferometerUniRankImageBox, null);
                toolTip1.SetToolTip(this.interferometerTSSRankImageBox, null);
            }
            if (interferometerSelectBox.Text == "Single-Wave Interferometer")
            {
                int weight = tempSpecialData[26, 0];
                int cost = tempSpecialData[26, 1];

                interferometerCostLabel.Text = string.Format("{0:N0}", cost);
                interferometerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "interferometer_single.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                interferometerPictureBox.ImageLocation = equipmentImageURL;

                int IFUniRank = int.Parse(tempSpecialData[26, 2].ToString().Remove(2, 2));
                int IFTSSRank = int.Parse(tempSpecialData[26, 2].ToString().Remove(0, 2));

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( IFTSSRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                interferometerTSSRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.interferometerTSSRankImageBox, rankName);

                rankName = rankData.ParseRankIDToString( IFUniRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                interferometerUniRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.interferometerUniRankImageBox, rankName);

                toolTip1.SetToolTip(this.interferometerInfoBox, "Stops ACS - Chance to successful interference: 99%");
                interferometerORLabel.Visible = true;
            }
            if (interferometerSelectBox.Text == "Dual-Wave Interferometer")
            {
                int weight = tempSpecialData[27, 0];
                int cost = tempSpecialData[27, 1];

                interferometerCostLabel.Text = string.Format("{0:N0}", cost);
                interferometerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "interferometer_dual.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                interferometerPictureBox.ImageLocation = equipmentImageURL;

                int IFUniRank = int.Parse(tempSpecialData[27, 2].ToString().Remove(3, 2));
                int IFTSSRank = int.Parse(tempSpecialData[27, 2].ToString().Remove(0, 3));

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( IFTSSRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                interferometerTSSRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.interferometerTSSRankImageBox, rankName);

                rankName = rankData.ParseRankIDToString( IFUniRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                interferometerUniRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.interferometerUniRankImageBox, rankName);

                toolTip1.SetToolTip(this.interferometerInfoBox, "Stops ACS - Chance to successful interference: 99.8%");
                interferometerORLabel.Visible = true;
            }
            if (interferometerSelectBox.Text == "Triple-Wave Interferometer")
            {
                int weight = tempSpecialData[28, 0];
                int cost = tempSpecialData[28, 1];

                interferometerCostLabel.Text = string.Format("{0:N0}", cost);
                interferometerWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "interferometer_triple.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                interferometerPictureBox.ImageLocation = equipmentImageURL;


                int IFTSSRank = tempSpecialData[28, 2];

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( IFTSSRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                interferometerTSSRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.interferometerTSSRankImageBox, rankName);
                interferometerUniRankImageBox.ImageLocation = null;

                toolTip1.SetToolTip(this.interferometerInfoBox, "Stops ACS - Chance to successful interference: 99.96%");
                interferometerORLabel.Visible = false;
            }
            calculateTotalSpecialCost();
            calculateTotalSpecialWeight();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void dampingFieldSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((dampingFieldSelectBox.Text == ":: No Damping Field ::") || (dampingFieldSelectBox.Text == ""))
            {
                dampingFieldPictureBox.ImageLocation = null;
                dampingFieldRankImageBox.ImageLocation = null;
                dampingFieldCostLabel.Text = "0";
                dampingFieldWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.dampingFieldInfoBox, null);
                toolTip1.SetToolTip(this.dampingFieldRankImageBox, null);
            }
            if (dampingFieldSelectBox.Text == "Damping Field Generator")
            {
                int weight = tempSpecialData[29, 0];
                int cost = tempSpecialData[29, 1];

                dampingFieldCostLabel.Text = string.Format("{0:N0}", cost);
                dampingFieldWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "damping_field_generator.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dampingFieldPictureBox.ImageLocation = equipmentImageURL;

                int dampingRank = tempSpecialData[29, 2];

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dampingRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dampingFieldRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dampingFieldRankImageBox, rankName);

                toolTip1.SetToolTip(this.dampingFieldInfoBox, "Decreases equipment damage in combat" + Environment.NewLine + " (including ship destruction during combat)" + Environment.NewLine + " and wormhole-accidents by 40%.");
            }
            if (dampingFieldSelectBox.Text == "Reinforced Damping Field Generator")
            {
                int weight = tempSpecialData[30, 0];
                int cost = tempSpecialData[30, 1];

                dampingFieldCostLabel.Text = string.Format("{0:N0}", cost);
                dampingFieldWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "damping_field_generator_reinforced.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dampingFieldPictureBox.ImageLocation = equipmentImageURL;

                int dampingRank = tempSpecialData[30, 2];

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dampingRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dampingFieldRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dampingFieldRankImageBox, rankName);

                toolTip1.SetToolTip(this.dampingFieldInfoBox, "Decreases equipment damage in combat" + Environment.NewLine + "(including ship destruction during combat)" + Environment.NewLine + "and wormhole-accidents by 55%.");
            }
            if (dampingFieldSelectBox.Text == "Perfected Damping Field Generator")
            {
                int weight = tempSpecialData[31, 0];
                int cost = tempSpecialData[31, 1];

                dampingFieldCostLabel.Text = string.Format("{0:N0}", cost);
                dampingFieldWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "damping_field_generator_perfected.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dampingFieldPictureBox.ImageLocation = equipmentImageURL;

                int dampingRank = tempSpecialData[31, 2];

                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dampingRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dampingFieldRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dampingFieldRankImageBox, rankName);

                toolTip1.SetToolTip(this.dampingFieldInfoBox, "Decreases equipment damage in combat" + Environment.NewLine + " (including ship destruction during combat)" + Environment.NewLine + " and wormhole-accidents by 65%.");
            }
            calculateTotalSpecialCost();
            calculateTotalSpecialWeight();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void dematSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if ((dematSelectBox.Text == ":: No Dematerializer ::") || (cloakerSelectBox.Text == ""))
            {
                dematPictureBox.ImageLocation = null;
                dematRankImageBox.ImageLocation = null;
                dematCostLabel.Text = "0";
                dematWeightLabel.Text = "0";
                toolTip1.SetToolTip(this.dematInfoBox, null);
                toolTip1.SetToolTip(this.dematRankImageBox, null);
            }
            if (dematSelectBox.Text == "Light Dematerializer Mk.I")
            {
                int weight = tempSpecialData[32, 0];
                int cost = tempSpecialData[32, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_light_mk1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[32, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 300+(size*20)." + Environment.NewLine + "Recovery time: 96 hours");
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.I")
            {
                int weight = tempSpecialData[33, 0];
                int cost = tempSpecialData[33, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_medium_mk1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[33, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 400+(size*8)." + Environment.NewLine + "Recovery time: 96 hours");
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.I")
            {
                int weight = tempSpecialData[34, 0];
                int cost = tempSpecialData[34, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_heavy_mk1.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[34, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 500+(size*1)." + Environment.NewLine + "Recovery time: 96 hours");
            }

            if (dematSelectBox.Text == "Light Dematerializer Mk.II")
            {
                int weight = tempSpecialData[35, 0];
                int cost = tempSpecialData[35, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_light_mk2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[35, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 300+(size*20)." + Environment.NewLine + "Recovery time: 72 hours");
            }
            if (dematSelectBox.Text == "Medium Dematerializer Mk.II")
            {
                int weight = tempSpecialData[36, 0];
                int cost = tempSpecialData[36, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_medium_mk2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[36, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 400+(size*8)." + Environment.NewLine + "Recovery time: 72 hours");
            }
            if (dematSelectBox.Text == "Heavy Dematerializer Mk.II")
            {
                int weight = tempSpecialData[37, 0];
                int cost = tempSpecialData[37, 1];

                dematCostLabel.Text = string.Format("{0:N0}", cost);
                dematWeightLabel.Text = weight.ToString();

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "dematerializer_heavy_mk2.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                dematPictureBox.ImageLocation = equipmentImageURL;

                int dematRank = tempSpecialData[37, 2];


                // Add rank images:
                string rankImageURL = "";
                string rankName = "";
                rankName = rankData.ParseRankIDToString( dematRank);
                rankImageURL = ConvertRankStringsToImagePaths(ref rankName);
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
                dematRankImageBox.ImageLocation = rankImageURL;
                toolTip1.SetToolTip(this.dematRankImageBox, rankName);

                toolTip1.SetToolTip(this.dematInfoBox, "Dematerialization with an AP cost of 500+(size*1)." + Environment.NewLine + "Recovery time: 72 hours");
            }
            calculateTotalSpecialCost();
            calculateTotalSpecialWeight();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }

        private void bodypartMaskerCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            int[,] tempSpecialData = SpecialData();

            if (bodypartMaskerCheckBox.Checked == true)
            {
                int weight = tempSpecialData[39, 0];
                int cost = tempSpecialData[39, 1];

                bodyPartMaskerCostLabel.Text = string.Format("{0:N0}", cost);
                bodyPartMaskerWeightLabel.Text = weight.ToString() + " (SU)";

                // Add equipment image
                string equipmentImageURL = Path.Combine("equipment", "bodypart_masker.png");
                string imagePackPath = GetImagePackPath();
                equipmentImageURL = Path.Combine(imagePackPath, equipmentImageURL);
                bodyPartMaskerPictureBox.ImageLocation = equipmentImageURL;


                // Add rank image:
                string rankImageURL = Path.Combine("factions", "sign_tss_16x16.png");
                rankImageURL = Path.Combine(imagePackPath, rankImageURL);
               bodypartMaskerRankImageBox.ImageLocation = rankImageURL;
               toolTip1.SetToolTip(this.bodypartMaskerRankImageBox, "Requires TSS Membership");

               toolTip1.SetToolTip(this.bodypartMaskerInfoBox, "Hides all bodyparts in your cargo from external scans");
            }
            else
            {
                bodyPartMaskerCostLabel.Text = "0";
                bodyPartMaskerWeightLabel.Text = "0";
                bodyPartMaskerPictureBox.ImageLocation = null;
                bodypartMaskerRankImageBox.ImageLocation = null;
                toolTip1.SetToolTip(this.bodypartMaskerInfoBox, null);
                toolTip1.SetToolTip(this.bodypartMaskerRankImageBox, null);
            }
            
            calculateTotalSpecialCost();
            CheckForRankRequirementConflicts();

            //Update Summary Page:
            updateSummaryPage();
        }
        #endregion

        #region summarypage
        private int calculateTotalLoadoutSpace()
        {
            int modeDriveSpace = 3;
            int modeShieldSpace = 2;
            int totalSpace;

            int gunSpace = freeSpaceRequiredForGuns();
            int missileSpace = aggregateMissileWeight();
            int driveSpace = ShipEquipment.GetDriveData(ref modeDriveSpace, driveSelectBox.Text);
            int shieldSpace = ShipEquipment.GetShieldData(ref modeShieldSpace, shieldSelectComboBox.Text);
            int specialWeight = calculateTotalSpecialWeight();


            totalSpace = (gunSpace + missileSpace + driveSpace + shieldSpace + specialWeight);
            totalLoadoutWeightLabel.Text = totalSpace.ToString();

            return totalSpace;
        }

        private int calculateTotalLoadoutCost()
        {
            int modeDriveCost = 5;
            int modeShieldCost = 3;
            int modeArmorCost = 1;
            int modeShipCost = 8;
            int totalCost;

            int gunCost = aggregateGunCost();
            int missileCost = aggregateMissileCost();
            int driveCost = ShipEquipment.GetDriveData(ref modeDriveCost, driveSelectBox.Text);
            int shieldCost = ShipEquipment.GetShieldData(ref modeShieldCost, shieldSelectComboBox.Text);
            int armorCost = GetArmorData(ref modeArmorCost);
            int specialCost = calculateTotalSpecialCost();
            int shipCost = playerShip.GetShipData(ref modeShipCost, shipSelectBox.Text);


            totalCost = (gunCost + missileCost + driveCost + armorCost + shieldCost + specialCost + shipCost);
            totalLoadoutCostLabel.Text = totalCost.ToString("N0");

            return totalCost;
        }

        private int freeSpaceRemaining()
        {
            int modeShipCapacity = 2;

            int shipCapacity = playerShip.GetShipData(ref modeShipCapacity, shipSelectBox.Text);
            int spaceUsed = calculateTotalLoadoutSpace();
            int spaceRemaining = shipCapacity - spaceUsed;

            freeSpaceRemainingLabel.Text = spaceRemaining.ToString();
            return spaceRemaining;
        }

        private double calculateRepairsAfterDeath()
        {
            int modeshipCost = 8;
            int modeArmorCost = 1;
            int modeShieldCost = 3;
            double repairsFactor = 15.0;

            int shipCost = playerShip.GetShipData(ref modeshipCost, shipSelectBox.Text);
            double loadoutCost = (double)calculateTotalLoadoutCost();
            int missileCost = aggregateMissileCost();
            int armorCost = GetArmorData(ref modeArmorCost);
            int shieldCost = ShipEquipment.GetShieldData(ref modeShieldCost, shieldSelectComboBox.Text);
            int specialCost = calculateTotalSpecialCost();

            loadoutCost = loadoutCost - (shipCost + shieldCost + armorCost + missileCost + specialCost);

            if (autoRefuelerCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[0, 1];
            }
            if (escapePodCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[1, 1];
            }
            if (fuelScoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[2, 1];
            }
            if (bussardRamscoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[3, 1];
            }
            if (magScoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[4, 1];
            }
            if (ambushTeleporterCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[5, 1];
            }
            if (teleporterComboBox.Text == "Class I Teleporter")
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[6, 1];
            }
            if (teleporterComboBox.Text == "Class II Teleporter")
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[7, 1];
            }

            // Add in damping field
            switch (dampingFieldSelectBox.Text)
            {
                case "Damping Field Generator":
                    repairsFactor = 9;
                    repairsAfterDeathLabelLabel.Text = "Repairs After Death (9%):";
                    break;

                case "Reinforced Damping Field Generator":
                    repairsFactor = 6.75;
                    repairsAfterDeathLabelLabel.Text = "Repairs After Death (6.75%):";
                    break;

                case "Perfected Damping Field Generator":
                    repairsFactor = 5.25;
                    repairsAfterDeathLabelLabel.Text = "Repairs After Death (5.25%):";
                    break;

                case ":: No Damping Field ::":
                    repairsFactor = 15;
                    repairsAfterDeathLabelLabel.Text = "Repairs After Death (15%):";
                    break;
            }


            // Divide by two to make it equal sell price.            
            loadoutCost = loadoutCost / 2;

            if (escapePodCheckBox.Checked == true)
            {
                loadoutCost = loadoutCost - 5000;
            }

            loadoutCost = (loadoutCost / 100) * repairsFactor;

            repairsAfterDeathLabel.Text = loadoutCost.ToString("N0");

            return loadoutCost;
        }

        private double calculateDailyMaintenance()
        {

            int modeArmorCost = 1;
            int modeshipCost = 8;
            int modeShieldCost = 3;

            // Equipment that doesn't degrade.
            int missileCost = aggregateMissileCost();
            int armorCost = GetArmorData(ref modeArmorCost);
            int shieldCost = ShipEquipment.GetShieldData(ref modeShieldCost, shieldSelectComboBox.Text);
            int shipCost = playerShip.GetShipData(ref modeshipCost, shipSelectBox.Text);
            double loadoutCost = (double)calculateTotalLoadoutCost();
            int specialCost = calculateTotalSpecialCost();

            loadoutCost = loadoutCost - (shipCost + shieldCost + armorCost + missileCost + specialCost);

            if (autoRefuelerCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[0, 1];
            }
            if (escapePodCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[1, 1];
            }
            if (fuelScoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[2, 1];
            }
            if (bussardRamscoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[3, 1];
            }
            if (magScoopCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[4, 1];
            }
            if (ambushTeleporterCheckBox.Checked == true)
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[5, 1];
            }
            if (teleporterComboBox.Text == "Class I Teleporter")
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[6, 1];
            }
            if (teleporterComboBox.Text == "Class II Teleporter")
            {
                int[,] tempdata = SpecialData();
                loadoutCost = loadoutCost + tempdata[7, 1];
            }


            // Divide by two to make it equal sell price.
            loadoutCost = loadoutCost / 2;


            loadoutCost = (loadoutCost / 100.0) * 0.5;

            dailyMaintenanceLabel.Text = loadoutCost.ToString("N0");

            return loadoutCost;
        }

        #endregion

        private void updateButton_Click(object sender, EventArgs e)
        {
            CheckForUpdates(false);
        }
        /// <summary>
        /// Linux: ~/./local/share/Tame Ship Calc
        /// Windows: C:/Users/Application Data/Local/TameShipCalc
        /// </summary>
        private void SetTameDirectoryPath()
        {
            // Tame Directory
            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            appdata = Path.Combine(appdata, "Tame Ship Calculator");

            if (!Directory.Exists(appdata))
            {
                Directory.CreateDirectory(appdata);
            }

            tameDirectory = appdata;

            shipFile = Path.Combine(tameDirectory, "ship_" + universe + ".xml");
            settingsFile = Path.Combine(tameDirectory, "settings.xml");
            pilotFile = Path.Combine(tameDirectory, "pilot_" + universe + ".xml");
            crewFile = Path.Combine(tameDirectory, "crew_" + universe + ".xml");
        }

        #region fscexport
        private void fscExportButton_Click(object sender, EventArgs e)
        {
            char[] trimChars = { '-', ' ' };
            string shipName = "Tame Import: " + shipSelectBox.Text.TrimStart(trimChars);
            string sep = "|";
            string total = "";
            bool exportError = false;
            
            FSC.FSC_Compatibility fsc = new FSC.FSC_Compatibility(fscVersion);

            // Strings
            string ship = "";
            string gun1 = "";
            string gun2 = "";
            string gun3 = "";
            string gun4 = "";
            string gun5 = "";
            string missileString = "";
            string[] missilearray = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
            int missileArrayIndex = 0;

            string armor = "";
            string shield = "";
            string drive = "";
            string autorefueller = "";
            string escapePod = "";
            string fuelscoop = "";
            string bussard = "";
            string magscoop = "";
            string ambushtele = "";
            string teleporter = "";
            string map = "";
            string bountylink = "";
            string ecm = "";
            string eccm = "";
            string cloaker = "";
            string dampingfield = "";
            string interferometer = "";
            string capacitor = "";
            string demat = "";
            string epsscanner = "";
            string kos = "";
            string gyro = "";
            string bodyPartMasker = "";
            string epsDrone = "";
            string bodyPart = "";

            // ComboBox Lookup modes
            int gunone = 1;
            int guntwo = 2;
            int gunthree = 3;
            int gunfour = 4;
            int gunfive = 5;
            int missile = 0;


            // Add ship
            ship = fsc.exportShipToFsc(shipSelectBox);
            if (ship == "ERROR")
            {
                exportError = true;
                MessageBox.Show("It is impossible to export a design without first selecting a ship", "No Ship!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Add Guns
            gun1 = exportGunToFSC(gunone);
            gun2 = exportGunToFSC(guntwo);
            gun3 = exportGunToFSC(gunthree);
            gun4 = exportGunToFSC(gunfour);
            gun5 = exportGunToFSC(gunfive);

            // Add Missiles
            for (missile = 1; missile < 26; missile++)
            {
                missileString = exportMissileToFSC(ref missile);
                missilearray[missileArrayIndex] = missileString;
                missileArrayIndex++;
            }
            missile = 0;
            missileArrayIndex = 0;

            // Add Armor
            armor = exportArmorToFSC();

            // Add Shield
            shield = exportShieldToFSC();

            // Add drive 
            drive = exportDriveToFSC();

            //Special
            #region special
            if (autoRefuelerCheckBox.Checked == true)
            {
                autorefueller = "1";
            }
            if (escapePodCheckBox.Checked == true)
            {
                escapePod = "1";
            }
            if (fuelScoopCheckBox.Checked == true)
            {
                fuelscoop = "1";
            }
            if (bussardRamscoopCheckBox.Checked == true)
            {
                bussard = "1";
            }
            if (magScoopCheckBox.Checked == true)
            {
                magscoop = "1";
            }
            if (ambushTeleporterCheckBox.Checked == true)
            {
                ambushtele = "1";
            }
            switch (teleporterComboBox.Text)
            {
                case "Class I Teleporter":
                    teleporter = "1";
                    break;
                case "Class II Teleporter":
                    teleporter = "2";
                    break;
                default:
                    teleporter = "";
                    break;
            }
            switch (mapPackComboBox.Text)
            {
                case "Map Pack I":
                    map = "1";
                    break;

                case "Map Pack II":
                    map = "2";
                    break;

                default:
                    map = "";
                    break;
            }
            switch (bountyLinkComboBox.Text)
            {
                case "Bounty Link I":
                    bountylink = "1";
                    break;

                case "Bounty Link II":
                    bountylink = "2";
                    break;

                case "Bounty Link III":
                    bountylink = "3";
                    break;

                default:
                    bountylink = "";
                    break;
            }
            switch (ecmJammerSelectBox.Text)
            {
                case "ECM Jammer":
                    ecm = "1";
                    break;

                case "Strong ECM Jammer":
                    ecm = "2";
                    break;

                default:
                    ecm = "";
                    break;
            }
            if (eccmJammerCheckBox.Checked == true)
            {
                eccm = "1";
            }
            switch (cloakerSelectBox.Text)
            {
                case "Cloaking Device":
                    cloaker = "2";
                    break;

                case "Improved Cloaking Device":
                    cloaker = "3";
                    break;

                default:
                    cloaker = "";
                    break;
            }
            switch (dampingFieldSelectBox.Text)
            {
                case "Damping Field Generator":
                    dampingfield = "1";
                    break;

                case "Reinforced Damping Field Generator":
                    dampingfield = "2";
                    break;

                case "Perfected Damping Field Generator":
                    dampingfield = "3";
                    break;

                default:
                    dampingfield = "";
                    break;
            }
            switch (interferometerSelectBox.Text)
            {
                case "Single-Wave Interferometer":
                    interferometer = "3";
                    break;

                case "Dual-Wave Interferometer":
                    interferometer = "4";
                    break;

                case "Triple-Wave Interferometer":
                    interferometer = "5";
                    break;

                default:
                    interferometer = "";
                    break;
            }
            switch (fluxCapacitorSelectBox.Text)
            {
                case "Weak Gas Flux Capacitor":
                    capacitor = "1";
                    break;

                case "Weak Energy Flux Capacitor":
                    capacitor = "2";
                    break;

                case "Strong Gas Flux Capacitor":
                    capacitor = "3";
                    break;

                case "Strong Energy Flux Capacitor":
                    capacitor = "4";
                    break;

                default:
                    capacitor = "";
                    break;
            }
            switch (dematSelectBox.Text)
            {
                case "Light Dematerializer Mk.I":
                    demat = "1";
                    break;

                case "Light Dematerializer Mk.II":
                    demat = "2";
                    break;

                case "Medium Dematerializer Mk.I":
                    demat = "3";
                    break;

                case "Medium Dematerializer Mk.II":
                    demat = "4";
                    break;

                case "Heavy Dematerializer Mk.I":
                    demat = "5";
                    break;

                case "Heavy Dematerializer Mk.II":
                    demat = "6";
                    break;

                default:
                    demat = "";
                    break;
            }
            if (epsContrabandScannerCheckBox.Checked == true)
            {
                epsscanner = "1";
            }
            if (keyOfSheppardCheckBox.Checked == true)
            {
                kos = "1";
            }
            switch (gyroStabiliserComboBox.Text)
            {
                case "Gyro Stabilizer I":
                    gyro = "1";
                    break;

                case "Gyro Stabilizer II":
                    gyro = "2";
                    break;

                default:
                    gyro = "";
                    break;
            }
            if (bodypartMaskerCheckBox.Checked == true)
            {
                bodyPartMasker = "1";
            }
            if (epsContrabandDroneCheckBox.Checked == true)
            {
                epsDrone = "1";
            }
            if (bodypartMaskerCheckBox.Checked == true)
            {
                bodyPart = "1";
            }
            #endregion


            if (!exportError)
            {
                total = fscVersion + sep + shipName + sep + ship + sep + gun1 + sep + gun2 + sep + gun3 + sep + gun4 + sep + gun5 + sep + sep;

                for (missile = 1; missile < 26; missile++)
                {
                    total = total + missilearray[missileArrayIndex] + sep;
                    missileArrayIndex++;
                }
                total = total + armor + sep + shield + sep + drive + sep /* This is the lucidi cloaker */+ sep + autorefueller + sep + escapePod + sep + fuelscoop + sep + bussard + sep + magscoop + sep + ambushtele + sep + teleporter + sep + map + sep + bountylink + sep + ecm + sep + eccm + sep + cloaker + sep + dampingfield + sep +
                    interferometer + sep + capacitor + sep + demat + sep + epsscanner + sep + kos + sep + gyro + sep + bodyPartMasker + sep + epsDrone + sep + bodyPart + sep;

                exportToFSCTextBox.Text = total;
            }
        }

        private string exportShipToFsc()
        {
            string ship;

            switch (shipSelectBox.Text)
            {
                case "":
                case " ":
                case "Neutral Ships":
                case "Federation Ships":
                case "Empire Ships":
                case "Union Ships":
                case "EPS Ships":
                case "TSS Ships":
                    ship = "ERROR";
                    return ship;

                case "- Sabre":
                    ship = "";
                    return ship;

                case "- Rustclaw":
                    ship = "1";
                    return ship;

                case "- Interceptor":
                    ship = "2";
                    return ship;

                case "- Lanner Mini":
                    ship = "3";
                    return ship;

                case "- Harrier":
                    ship = "4";
                    return ship;

                case "- Mercury":
                    ship = "5";
                    return ship;

                case "- Hercules":
                    ship = "6";
                    return ship;

                case "- Lanner":
                    ship = "7";
                    return ship;

                case "- Hawk":
                    ship = "8";
                    return ship;

                case "- Gargantua":
                    ship = "9";
                    return ship;

                case "- Behemoth":
                    ship = "10";
                    return ship;

                case "- Liberator":
                    ship = "11";
                    return ship;


                case "- Wasp":
                    ship = "12";
                    return ship;

                case "- Adder":
                    ship = "13";
                    return ship;

                case "- Thunderbird":
                    ship = "14";
                    return ship;

                case "- Viper Defence Craft":
                    ship = "15";
                    return ship;

                case "- Babel Transporter":
                    ship = "16";
                    return ship;

                case "- Piranha":
                    ship = "17";
                    return ship;

                case "- Nighthawk":
                    ship = "18";
                    return ship;

                case "- Nighthawk Deluxe":
                    ship = "19";
                    return ship;

                case "- Mantis":
                    ship = "20";
                    return ship;

                case "- Extender":
                    ship = "21";
                    return ship;

                case "- Gauntlet":
                    ship = "22";
                    return ship;

                case "- Doomstar":
                    ship = "23";
                    return ship;

                case "- War Nova":
                    ship = "24";
                    return ship;

                case "- Ficon":
                    ship = "25";
                    return ship;

                case "- Tyrant":
                    ship = "26";
                    return ship;

                case "- Spectre":
                    ship = "27";
                    return ship;

                case "- Shadow Stealth Craft":
                    ship = "28";
                    return ship;

                case "- Venom":
                    ship = "29";
                    return ship;

                case "- Constrictor":
                    ship = "30";
                    return ship;

                case "- Phantom Advanced Stealth Craft":
                    ship = "31";
                    return ship;

                case "- Dominator":
                    ship = "32";
                    return ship;

                case "- Boa Ultimate Carrier":
                    ship = "33";
                    return ship;

                case "- Mooncrusher":
                    ship = "34";
                    return ship;

                case "- Rustfire":
                    ship = "35";
                    return ship;

                case "- Marauder":
                    ship = "36";
                    return ship;

                case "- Junker IV":
                    ship = "37";
                    return ship;

                case "- Slider":
                    ship = "38";
                    return ship;

                case "- El Padre":
                    ship = "39";
                    return ship;

                case "- Chitin":
                    ship = "40";
                    return ship;

                case "- Horpor":
                    ship = "41";
                    return ship;

                case "- Scorpion":
                    ship = "42";
                    return ship;

                case "- Trident":
                    ship = "43";
                    return ship;

                case "- Celeus":
                    ship = "44";
                    return ship;

                case "- Pantagruel":
                    ship = "45";
                    return ship;

                case "- Vulcan":
                    ship = "46";
                    return ship;

                case "- Nano":
                    ship = "47";
                    return ship;

                case "- Liberator EPS":
                    ship = "48";
                    return ship;

                case "- Rover":
                    ship = "49";
                    return ship;

                case "- Reaper":
                    ship = "50";
                    return ship;

                case "- Blood Lanner":
                    ship = "51";
                    return ship;

                case "- Sudden Death":
                    ship = "52";
                    return ship;
            }
            return "ERROR";
        }

        private string exportGunToFSC(int gunbox)
        {
            string gun;
            ComboBox comboBox = null;

            if (gunbox == 1)
            {
                comboBox = gunLoadoutComboBox1;
            }
            if (gunbox == 2)
            {
                comboBox = gunLoadoutComboBox2;
            }
            if (gunbox == 3)
            {
                comboBox = gunLoadoutComboBox3;
            }
            if (gunbox == 4)
            {
                comboBox = gunLoadoutComboBox4;
            }
            if (gunbox == 5)
            {
                comboBox = gunLoadoutComboBox5;
            }

            switch (comboBox.Text)
            {
                case "10MW Mining Laser":
                    gun = "1";
                    return gun;

                case "30MW Mining Laser":
                    gun = "2";
                    return gun;

                case "1MW Impulse Laser":
                    gun = "3";
                    return gun;

                case "5MW Impulse Laser":
                    gun = "4";
                    return gun;

                case "1MW Particle Laser":
                    gun = "5";
                    return gun;

                case "4MW Particle Laser":
                    gun = "6";
                    return gun;

                case "4MW LW Particle Laser":
                    gun = "7";
                    return gun;

                case "20MW Particle Laser":
                    gun = "8";
                    return gun;

                case "20MW LW Particle Laser":
                    gun = "9";
                    return gun;

                case "100MW Particle Laser":
                    gun = "10";
                    return gun;

                case "100MW LW Particle Laser":
                    gun = "11";
                    return gun;

                case "140MW Particle Laser":
                    gun = "12";
                    return gun;

                case "140MW LW Particle Laser":
                    gun = "13";
                    return gun;

                case "4MW Gatling Laser":
                    gun = "14";
                    return gun;

                case "4MW LW Gatling Laser":
                    gun = "15";
                    return gun;

                case "6MW Gatling Laser":
                    gun = "16";
                    return gun;

                case "6MW LW Gatling Laser ":
                    gun = "17";
                    return gun;

                case "10MW Gatling Laser":
                    gun = "18";
                    return gun;

                case "10MW LW Gatling Laser":
                    gun = "19";
                    return gun;

                case "20MW Gatling Laser":
                    gun = "20";
                    return gun;

                case "20MW LW Gatling Laser":
                    gun = "21";
                    return gun;

                case "35MW Plasma":
                    gun = "22";
                    return gun;

                case "40MW Plasma":
                    gun = "23";
                    return gun;

                case "60MW Plasma":
                    gun = "24";
                    return gun;

                case "Exoplasm Launcher":
                    gun = "25";
                    return gun;

                case "Endoplasm Launcher":
                    gun = "26";
                    return gun;

                case "Bio-Spore Array":
                    gun = "27";
                    return gun;

                case "Viral Glands":
                    gun = "28";
                    return gun;

                case "80MT Magnetic Defractor":
                    gun = "29";
                    return gun;

                case "120MT Magnetic Defractor":
                    gun = "30";
                    return gun;

                case "Large Pulse Cannon":
                    gun = "31";
                    return gun;

                case "Very Large Pulse Cannon":
                    gun = "32";
                    return gun;

                case "Lucidi Enforcer I":
                    gun = "33";
                    return gun;

                case "Lucidi Enforcer II":
                    gun = "34";
                    return gun;

                case "Lucidi Conqueror":
                    gun = "35";
                    return gun;

                case "Lucidi Plasma Thrower":
                    gun = "36";
                    return gun;

                default:
                    return "";
            }
        }

        private string exportMissileToFSC(ref int missileBox)
        {
            string missile = "";
            ComboBox comboBox = null;

            switch (missileBox)
            {
                case 1:
                    comboBox = missileLoadoutComboBox1;
                    break;

                case 2:
                    comboBox = missileLoadoutComboBox2;
                    break;

                case 3:
                    comboBox = missileLoadoutComboBox3;
                    break;

                case 4:
                    comboBox = missileLoadoutComboBox4;
                    break;

                case 5:
                    comboBox = missileLoadoutComboBox5;
                    break;

                case 6:
                    comboBox = missileLoadoutComboBox6;
                    break;

                case 7:
                    comboBox = missileLoadoutComboBox7;
                    break;

                case 8:
                    comboBox = missileLoadoutComboBox8;
                    break;

                case 9:
                    comboBox = missileLoadoutComboBox9;
                    break;

                case 10:
                    comboBox = missileLoadoutComboBox10;
                    break;

                case 11:
                    comboBox = missileLoadoutComboBox11;
                    break;

                case 12:
                    comboBox = missileLoadoutComboBox12;
                    break;

                case 13:
                    comboBox = missileLoadoutComboBox13;
                    break;

                case 14:
                    comboBox = missileLoadoutComboBox14;
                    break;

                case 15:
                    comboBox = missileLoadoutComboBox15;
                    break;

                case 16:
                    comboBox = missileLoadoutComboBox16;
                    break;

                case 17:
                    comboBox = missileLoadoutComboBox17;
                    break;

                case 18:
                    comboBox = missileLoadoutComboBox18;
                    break;

                case 19:
                    comboBox = missileLoadoutComboBox19;
                    break;

                case 20:
                    comboBox = missileLoadoutComboBox20;
                    break;

                case 21:
                    comboBox = missileLoadoutComboBox21;
                    break;

                case 22:
                    comboBox = missileLoadoutComboBox22;
                    break;

                case 23:
                    comboBox = missileLoadoutComboBox23;
                    break;

                case 24:
                    comboBox = missileLoadoutComboBox24;
                    break;

                case 25:
                    comboBox = missileLoadoutComboBox25;
                    break;
            }

            switch (comboBox.Text)
            {
                case "P80 Sidewinder":
                    missile = "1";
                    return missile;

                case "KL760 Homing":
                    missile = "2";
                    return missile;

                case "LV111 Intelligent":
                    missile = "3";
                    return missile;

                case "NN500 Fleet":
                    missile = "4";
                    return missile;

                case "NN550 Fleet":
                    missile = "5";
                    return missile;

                case "Imperial MO89 Lord":
                    missile = "6";
                    return missile;

                case "Imperial G-7 Smartwinder":
                    missile = "7";
                    return missile;

                case "A/50 Pogo":
                    missile = "8";
                    return missile;

                case "D/70 Havar":
                    missile = "9";
                    return missile;

                case "Imperial Elite Mk.I":
                    missile = "10";
                    return missile;

                case "Imperial Elite Mk.II":
                    missile = "11";
                    return missile;

                case "King Relon":
                    missile = "12";
                    return missile;

                case "King Kraak":
                    missile = "13";
                    return missile;

                case "Royal Redeemer":
                    missile = "14";
                    return missile;

                default:
                    missile = "";
                    return missile;
            }
        }

        private string exportArmorToFSC()
        {
            string armorReturnData = "";

            switch (armorComboBox.Text)
            {
                case "Titanium (x1)":
                    armorReturnData = "1";
                    return armorReturnData;

                case "Tritanium (x2)":
                    armorReturnData = "2";
                    return armorReturnData;

                case "Zortrium (x3)":
                    armorReturnData = "3";
                    return armorReturnData;

                case "Neutronium (x4)":
                    armorReturnData = "4";
                    return armorReturnData;

                case "Adamantium (x5)":
                    armorReturnData = "5";
                    return armorReturnData;

                case "Ebidium (x6)":
                    armorReturnData = "6";
                    return armorReturnData;

                case "Worm-Slime (x2)":
                    armorReturnData = "7";
                    return armorReturnData;

                case "Mykoplasmic (x3)":
                    armorReturnData = "8";
                    return armorReturnData;

                case "Mutagen (x4)":
                    armorReturnData = "9";
                    return armorReturnData;

                case "Genotrope (x5)":
                    armorReturnData = "10";
                    return armorReturnData;

                case "Fermion (x2)":
                    armorReturnData = "11";
                    return armorReturnData;

                case "Boson (x3)":
                    armorReturnData = "12";
                    return armorReturnData;

                case "Positron (x4)":
                    armorReturnData = "13";
                    return armorReturnData;

                case "Anti-Neutrino (x5)":
                    armorReturnData = "14";
                    return armorReturnData;

                case "Pardus I":
                    armorReturnData = "15";
                    return armorReturnData;

                case "Pardus II":
                    armorReturnData = "16";
                    return armorReturnData;

                case "Pardus III":
                    armorReturnData = "17";
                    return armorReturnData;

                case "Pardus IV":
                    armorReturnData = "18";
                    return armorReturnData;

                case "Pardus V":
                    armorReturnData = "19";
                    return armorReturnData;

                case "Pardus VI":
                    armorReturnData = "20";
                    return armorReturnData;

                default:
                    armorReturnData = "";
                    return armorReturnData;

            }
        }

        private string exportShieldToFSC()
        {
            string shieldReturnData = "";

            switch (shieldSelectComboBox.Text)
            {
                case "Small":
                    shieldReturnData = "1";
                    return shieldReturnData;

                case "Standard":
                    shieldReturnData = "2";
                    return shieldReturnData;

                case "Medium":
                    shieldReturnData = "3";
                    return shieldReturnData;

                case "Large":
                    shieldReturnData = "4";
                    return shieldReturnData;

                case "Tiny":
                    shieldReturnData = "5";
                    return shieldReturnData;

                case "Q-Small":
                    shieldReturnData = "6";
                    return shieldReturnData;

                case "Q-Standard":
                    shieldReturnData = "7";
                    return shieldReturnData;

                case "Q-Medium":
                    shieldReturnData = "8";
                    return shieldReturnData;

                case "Q-Large":
                    shieldReturnData = "9";
                    return shieldReturnData;

                case "Huge":
                    shieldReturnData = "10";
                    return shieldReturnData;

                case "Q-Huge":
                    shieldReturnData = "11";
                    return shieldReturnData;

                case "L-Huge":
                    shieldReturnData = "12";
                    return shieldReturnData;

                case "LQ-Large":
                    shieldReturnData = "13";
                    return shieldReturnData;

                case "LQ-Huge":
                    shieldReturnData = "14";
                    return shieldReturnData;

                default:
                    shieldReturnData = "";
                    return shieldReturnData;
            }
        }

        private string exportDriveToFSC()
        {
            string driveReturnData = "";

            switch (driveSelectBox.Text)
            {
                case "Nuclear Drive":
                    driveReturnData = "1";
                    return driveReturnData;

                case "Fusion Drive":
                    driveReturnData = "2";
                    return driveReturnData;

                case "Enhanced Fusion Drive":
                    driveReturnData = "7";
                    return driveReturnData;

                case "Ion Drive":
                    driveReturnData = "3";
                    return driveReturnData;

                case "Antimatter Drive":
                    driveReturnData = "4";
                    return driveReturnData;

                case "Enhanced Antimatter Drive":
                    driveReturnData = "8";
                    return driveReturnData;

                case "Hyper Drive":
                    driveReturnData = "5";
                    return driveReturnData;

                case "Interphased Drive":
                    driveReturnData = "6";
                    return driveReturnData;

                case "Enhanced Interphased Drive":
                    driveReturnData = "9";
                    return driveReturnData;

                default:
                    driveReturnData = "";
                    return driveReturnData;
            }
        }
        #endregion

        #region fscImporting

        private void fscImportButton_Click(object sender, EventArgs e)
        {
            DialogResult importDialogResult = MessageBox.Show("Importing FSC Loadout: Doing this will overwrite any design currently in the designer, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (importDialogResult == DialogResult.Yes)
            {
                string separator = "|";
                int i;
                string fscImportString = "";              
                string[] import;
                string[] fscV;
                bool inputError = false;
                bool supportedVersionFound = false;

                // Tells functions which equipment selection box we're talking about.
                int gun;
                int missile;

                FSC.FSC_Compatibility fsc = new FSC.FSC_Compatibility(fscVersion);
                fscV = fsc.getFSC_Version();

                for (i = 0; i < exportToFSCTextBox.Lines.Length; i++)
                {
                    fscImportString += exportToFSCTextBox.Lines[i];
                }

                try
                {
                    import = fscImportString.Split(separator.ToCharArray());
                    if (exportToFSCTextBox.Text == "")
                    {
                        inputError = true;
                        MessageBox.Show("Error, can't import nothing." + Environment.NewLine + " Please put something in the text box.", "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if (!inputError)
                    {
                        for (i = 0; i < fscV.Length; i++)
                        {
                            if (import[0] == fscV[i])
                            {                                
                                supportedVersionFound = true;
                            }
                        }
                        if (supportedVersionFound == false)
                        {
                            MessageBox.Show(string.Format("Error, either you're attempting to import from an incompatible FSC version. Or You have not entered a valid FSC string.", fscVersion), "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            inputError = true;
                        }
                    }
                    if (!inputError)
                    {
                        // Import Ship
                        parseShipID(import[2]);

                        // Import Guns
                        gun = 1;
                        parseGunID(ref gun, ref import);
                        gun = 2;
                        parseGunID(ref gun, ref import);
                        gun = 3;
                        parseGunID(ref gun, ref import);
                        gun = 4;
                        parseGunID(ref gun, ref import);
                        gun = 5;
                        parseGunID(ref gun, ref import);

                        // Missiles Array index import[8] appears unused.
                        for (missile = 1; missile < 26; missile++)
                        {
                            parseMissileID(ref missile, ref import);
                        }
                        // Import Armor.
                        parseArmorID(ref import);

                        // Import Shield
                        parseShieldID(ref import);

                        // Import Drive
                        parseDriveID(ref import);

                        // Import Special Equipment
                        // Import[37] is lucidi cloaker. Pointless.
                        if (import[38] == "1")
                        {
                            autoRefuelerCheckBox.Checked = true;
                        }
                        else
                        {
                            autoRefuelerCheckBox.Checked = false;
                        }
                        if (import[39] == "1")
                        {
                            escapePodCheckBox.Checked = true;
                        }
                        else
                        {
                            escapePodCheckBox.Checked = false;
                        }
                        if (import[40] == "1")
                        {
                            fuelScoopCheckBox.Checked = true;
                        }
                        else
                        {
                            fuelScoopCheckBox.Checked = false;
                        }
                        if (import[41] == "1")
                        {
                            bussardRamscoopCheckBox.Checked = true;
                        }
                        else
                        {
                            bussardRamscoopCheckBox.Checked = false;
                        }
                        if (import[42] == "1")
                        {
                            magScoopCheckBox.Checked = true;
                        }
                        else
                        {
                            magScoopCheckBox.Checked = false;
                        }
                        if (import[43] == "1")
                        {
                            ambushTeleporterCheckBox.Checked = true;
                        }
                        else
                        {
                            ambushTeleporterCheckBox.Checked = false;
                        }
                        // Teleporters
                        switch (import[44])
                        {
                            case "":
                                teleporterComboBox.Text = ":: No Teleporter ::";
                                break;

                            case "1":
                                teleporterComboBox.Text = "Class I Teleporter";
                                break;

                            case "2":
                                teleporterComboBox.Text = "Class II Teleporter";
                                break;
                        }
                        // Maps
                        switch (import[45])
                        {
                            case "":
                                mapPackComboBox.Text = ":: No Map Pack ::";
                                break;

                            case "1":
                                mapPackComboBox.Text = "Map Pack I";
                                break;

                            case "2":
                                mapPackComboBox.Text = "Map Pack II";
                                break;
                        }
                        // Bounty Link
                        switch (import[46])
                        {
                            case "":
                                bountyLinkComboBox.Text = ":: No Bounty Link ::";
                                break;

                            case "1":
                                bountyLinkComboBox.Text = "Bounty Link I";
                                break;

                            case "2":
                                bountyLinkComboBox.Text = "Bounty Link II";
                                break;

                            case "3":
                                bountyLinkComboBox.Text = "Bounty Link III";
                                break;
                        }
                        // ECM
                        switch (import[47])
                        {
                            case "":
                                ecmJammerSelectBox.Text = ":: No Jammer ::";
                                break;

                            case "1":
                                ecmJammerSelectBox.Text = "ECM Jammer";
                                break;

                            case "2":
                                ecmJammerSelectBox.Text = "Strong ECM Jammer";
                                break;
                        }
                        // ECCM
                        if (import[48] == "1")
                        {
                            eccmJammerCheckBox.Checked = true;
                        }
                        else
                        {
                            eccmJammerCheckBox.Checked = false;
                        }
                        // Cloak
                        switch (import[49])
                        {
                            case "":
                                cloakerSelectBox.Text = ":: No Cloaker ::";
                                break;

                            case "1":
                            case "2":
                                cloakerSelectBox.Text = "Cloaking Device";
                                break;

                            case "3":
                                cloakerSelectBox.Text = "Improved Cloaking Device";
                                break;
                        }
                        // Damping Field
                        switch (import[50])
                        {
                            case "":
                                dampingFieldSelectBox.Text = ":: No Damping Field ::";
                                break;

                            case "1":
                                dampingFieldSelectBox.Text = "Damping Field Generator";
                                break;

                            case "2":
                                dampingFieldSelectBox.Text = "Reinforced Damping Field Generator";
                                break;

                            case "3":
                                dampingFieldSelectBox.Text = "Perfected Damping Field Generator";
                                break;
                        }
                        // IF
                        switch (import[51])
                        {
                            case "":
                                interferometerSelectBox.Text = ":: No Interferometer ::";
                                break;

                            case "1":
                            case "3":
                                interferometerSelectBox.Text = "Single-Wave Interferometer";
                                break;

                            case "2":
                            case "4":
                                interferometerSelectBox.Text = "Dual-Wave Interferometer";
                                break;

                            case "5":
                                interferometerSelectBox.Text = "Triple-Wave Interferometer";
                                break;
                        }
                        //fluxies
                        switch (import[52])
                        {
                            case "":
                                fluxCapacitorSelectBox.Text = ":: No Capacitor ::";
                                break;

                            case "1":
                                fluxCapacitorSelectBox.Text = "Weak Gas Flux Capacitor";
                                break;

                            case "2":
                                fluxCapacitorSelectBox.Text = "Weak Energy Flux Capacitor";
                                break;

                            case "3":
                                fluxCapacitorSelectBox.Text = "Strong Gas Flux Capacitor";
                                break;

                            case "4":
                                fluxCapacitorSelectBox.Text = "Strong Energy Flux Capacitor";
                                break;
                        }
                        // Demat
                        switch (import[53])
                        {
                            case "":
                                dematSelectBox.Text = ":: No Dematerializer ::";
                                break;

                            case "1":
                                dematSelectBox.Text = "Light Dematerializer Mk.I";
                                break;

                            case "3":
                                dematSelectBox.Text = "Medium Dematerializer Mk.I";
                                break;

                            case "5":
                                dematSelectBox.Text = "Heavy Dematerializer Mk.I";
                                break;

                            case "2":
                                dematSelectBox.Text = "Light Dematerializer Mk.II";
                                break;

                            case "4":
                                dematSelectBox.Text = "Medium Dematerializer Mk.II";
                                break;

                            case "6":
                                dematSelectBox.Text = "Heavy Dematerializer Mk.II";
                                break;

                        }
                        // EPS Scanner
                        switch (import[54])
                        {
                            case "1": epsContrabandScannerCheckBox.Checked = true; break;

                            case "2": epsContrabandDroneCheckBox.Checked = true; break;

                            default: epsContrabandDroneCheckBox.Checked = false; epsContrabandScannerCheckBox.Checked = false; break;
                        }
                        
                    
                        
                        // KOS
                        if (import[55] == "1")
                        {
                            keyOfSheppardCheckBox.Checked = true;
                        }
                        else
                        {
                            keyOfSheppardCheckBox.Checked = false;
                        }
                        // Gyro
                        switch (import[56])
                        {
                            case "":
                                gyroStabiliserComboBox.Text = ":: No Gyro ::";
                                break;

                            case "1":
                                gyroStabiliserComboBox.Text = "Gyro Stabilizer I";
                                break;

                            case "2":
                                gyroStabiliserComboBox.Text = "Gyro Stabilizer II";
                                break;
                        }
                        // EPS Drone
                        if (import[57] == "1")
                        {

                            epsContrabandDroneCheckBox.Checked = true;
                        }
                        else
                        {
                            epsContrabandDroneCheckBox.Checked = false;
                        }

                        // TSS Body Part Masker
                        if (import[58] == "1")
                        {
                            bodypartMaskerCheckBox.Checked = true;
                        }
                        else
                        {
                            bodypartMaskerCheckBox.Checked = false;
                        }

                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Oops, something went wrong with the import. Try removing all the text from the box and pasting in the FSC string again, and make sure you copied ALL the text from FSC.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

        private void parseShipID(string import)
        {
            switch (import)
            {
                case "":
                    shipSelectBox.Text = "- Sabre";
                    break;

                case "1":
                    shipSelectBox.Text = "- Rustclaw";
                    break;

                case "2":
                    shipSelectBox.Text = "- Interceptor";
                    break;

                case "3":
                    shipSelectBox.Text = "- Lanner Mini";
                    break;

                case "4":
                    shipSelectBox.Text = "- Harrier";
                    break;

                case "5":
                    shipSelectBox.Text = "- Mercury";
                    break;

                case "6":
                    shipSelectBox.Text = "- Hercules";
                    break;

                case "7":
                    shipSelectBox.Text = "- Lanner";
                    break;

                case "8":
                    shipSelectBox.Text = "- Hawk";
                    break;

                case "9":
                    shipSelectBox.Text = "- Gargantua";
                    break;

                case "10":
                    shipSelectBox.Text = "- Behemoth";
                    break;

                case "11":
                    shipSelectBox.Text = "- Liberator";
                    break;

                case "12":
                    shipSelectBox.Text = "- Leviathan";
                    break;

                case "13":
                    shipSelectBox.Text = "- Wasp";
                    break;

                case "14":
                    shipSelectBox.Text = "- Adder";
                    break;

                case "15":
                    shipSelectBox.Text = "- Thunderbird";
                    break;

                case "16":
                    shipSelectBox.Text = "- Viper Defence Craft";
                    break;

                case "17":
                    shipSelectBox.Text = "- Babel Transporter";
                    break;

                case "18":
                    shipSelectBox.Text = "- Piranha";
                    break;

                case "19":
                    shipSelectBox.Text = "- Nighthawk";
                    break;

                case "20":
                    shipSelectBox.Text = "- Nighthawk Deluxe";
                    break;

                case "21":
                    shipSelectBox.Text = "- Mantis";
                    break;

                case "22":
                    shipSelectBox.Text = "- Extender";
                    break;

                case "23":
                    shipSelectBox.Text = "- Gauntlet";
                    break;

                case "24":
                    shipSelectBox.Text = "- Doomstar";
                    break;

                case "25":
                    shipSelectBox.Text = "- War Nova";
                    break;

                case "26":
                    shipSelectBox.Text = "- Ficon";
                    break;

                case "27":
                    shipSelectBox.Text = "- Tyrant";
                    break;

                case "28":
                    shipSelectBox.Text = "- Spectre";
                    break;

                case "29":
                    shipSelectBox.Text = "- Shadow Stealth Craft";
                    break;

                case "30":
                    shipSelectBox.Text = "- Venom";
                    break;

                case "31":
                    shipSelectBox.Text = "- Constrictor";
                    break;

                case "32":
                    shipSelectBox.Text = "- Phantom Advanced Stealth Craft";
                    break;

                case "33":
                    shipSelectBox.Text = "- Dominator";
                    break;

                case "34":
                    shipSelectBox.Text = "- Boa Ultimate Carrier";
                    break;

                case "35":
                    shipSelectBox.Text = "- Mooncrusher";
                    break;

                case "36":
                    shipSelectBox.Text = "- Rustfire";
                    break;

                case "37":
                    shipSelectBox.Text = "- Marauder";
                    break;

                case "38":
                    shipSelectBox.Text = "- Junker IV";
                    break;

                case "39":
                    shipSelectBox.Text = "- Slider";
                    break;

                case "40":
                    shipSelectBox.Text = "- El Padre";
                    break;

                case "41":
                    shipSelectBox.Text = "- Chitin";
                    break;

                case "42":
                    shipSelectBox.Text = "- Horpor";
                    break;

                case "43":
                    shipSelectBox.Text = "- Scorpion";
                    break;

                case "44":
                    shipSelectBox.Text = "- Trident";
                    break;

                case "45":
                    shipSelectBox.Text = "- Celeus";
                    break;

                case "46":
                    shipSelectBox.Text = "- Pantagruel";
                    break;

                case "47":
                    shipSelectBox.Text = "- Vulcan";
                    break;

                case "48":
                    shipSelectBox.Text = "- Nano";
                    break;

                case "49":
                    shipSelectBox.Text = "- Liberator EPS";
                    break;

                case "50":
                    shipSelectBox.Text = "- Rover";
                    break;

                case "51":
                    shipSelectBox.Text = "- Reaper";
                    break;

                case "52":
                    shipSelectBox.Text = "- Blood Lanner";
                    break;

                case "53":
                    shipSelectBox.Text = "- Sudden Death";
                    break;
            }
        }

        private void parseGunID(ref int gun, ref string[] import)
        {
            ComboBox comboBox = null;
            int importIndex = 0;

            switch (gun)
            {
                case 1:
                    comboBox = gunLoadoutComboBox1;
                    importIndex = 3;
                    break;

                case 2:
                    comboBox = gunLoadoutComboBox2;
                    importIndex = 4;
                    break;

                case 3:
                    comboBox = gunLoadoutComboBox3;
                    importIndex = 5;
                    break;

                case 4:
                    comboBox = gunLoadoutComboBox4;
                    importIndex = 6;
                    break;

                case 5:
                    comboBox = gunLoadoutComboBox5;
                    importIndex = 7;
                    break;
            }

            if (comboBox.Enabled == true)
            {
                switch (import[importIndex])
                {
                    case "":
                        comboBox.Text = ":: None ::";
                        break;

                    case "1":
                        comboBox.Text = "10MW Mining Laser";
                        break;

                    case "2":
                        comboBox.Text = "30MW Mining Laser";
                        break;

                    case "3":
                        comboBox.Text = "1MW Impulse Laser";
                        break;

                    case "4":
                        comboBox.Text = "5MW Impulse Laser";
                        break;

                    case "5":
                        comboBox.Text = "1MW Particle Laser";
                        break;

                    case "6":
                        comboBox.Text = "4MW Particle Laser";
                        break;

                    case "7":
                        comboBox.Text = "4MW LW Particle Laser";
                        break;

                    case "8":
                        comboBox.Text = "20MW Particle Laser";
                        break;

                    case "9":
                        comboBox.Text = "20MW LW Particle Laser";
                        break;

                    case "10":
                        comboBox.Text = "100MW Particle Laser";
                        break;

                    case "11":
                        comboBox.Text = "100MW LW Particle Laser";
                        break;

                    case "12":
                        comboBox.Text = "140MW Particle Laser";
                        break;

                    case "13":
                        comboBox.Text = "140MW LW Particle Laser";
                        break;
                    case "14":
                        comboBox.Text = "4MW Gatling Laser";
                        break;

                    case "15":
                        comboBox.Text = "4MW LW Gatling Laser";
                        break;

                    case "16":
                        comboBox.Text = "6MW Gatling Laser";
                        break;

                    case "17":
                        comboBox.Text = "6MW LW Gatling Laser";
                        break;

                    case "18":
                        comboBox.Text = "10MW Gatling Laser";
                        break;

                    case "19":
                        comboBox.Text = "10MW LW Gatling Laser";
                        break;

                    case "20":
                        comboBox.Text = "20MW Gatling Laser";
                        break;

                    case "21":
                        comboBox.Text = "20MW LW Gatling Laser";
                        break;

                    case "22":
                        comboBox.Text = "35MW Plasma";
                        break;

                    case "23":
                        comboBox.Text = "40MW Plasma";
                        break;

                    case "24":
                        comboBox.Text = "60MW Plasma";
                        break;

                    case "25":
                        comboBox.Text = "Exoplasm Launcher";
                        break;

                    case "26":
                        comboBox.Text = "Endoplasm Launcher";
                        break;

                    case "27":
                        comboBox.Text = "Bio-Spore Array";
                        break;

                    case "28":
                        comboBox.Text = "Viral Glands";
                        break;

                    case "29":
                        comboBox.Text = "80MT Magnetic Defractor";
                        break;

                    case "30":
                        comboBox.Text = "120MT Magnetic Defractor";
                        break;

                    case "31":
                        comboBox.Text = "Large Pulse Cannon";
                        break;

                    case "32":
                        comboBox.Text = "Very Large Pulse Cannon";
                        break;

                    case "33":
                        comboBox.Text = "Lucidi Enforcer I";
                        break;

                    case "34":
                        comboBox.Text = "Lucidi Enforcer II";
                        break;

                    case "35":
                        comboBox.Text = "Lucidi Conqueror";
                        break;

                    case "36":
                        comboBox.Text = "Lucidi Plasma Thrower";
                        break;
                }
            }

        }

        private void parseMissileID(ref int missile, ref string[] import)
        {
            ComboBox comboBox = null;
            int importIndex = 0;

            switch (missile)
            {
                case 1:
                    comboBox = missileLoadoutComboBox1;
                    importIndex = 9;
                    break;

                case 2:
                    comboBox = missileLoadoutComboBox2;
                    importIndex = 10;
                    break;

                case 3:
                    comboBox = missileLoadoutComboBox3;
                    importIndex = 11;
                    break;

                case 4:
                    comboBox = missileLoadoutComboBox4;
                    importIndex = 12;
                    break;

                case 5:
                    comboBox = missileLoadoutComboBox5;
                    importIndex = 13;
                    break;

                case 6:
                    comboBox = missileLoadoutComboBox6;
                    importIndex = 14;
                    break;

                case 7:
                    comboBox = missileLoadoutComboBox7;
                    importIndex = 15;
                    break;

                case 8:
                    comboBox = missileLoadoutComboBox8;
                    importIndex = 16;
                    break;

                case 9:
                    comboBox = missileLoadoutComboBox9;
                    importIndex = 17;
                    break;

                case 10:
                    comboBox = missileLoadoutComboBox10;
                    importIndex = 18;
                    break;

                case 11:
                    comboBox = missileLoadoutComboBox11;
                    importIndex = 19;
                    break;

                case 12:
                    comboBox = missileLoadoutComboBox12;
                    importIndex = 20;
                    break;

                case 13:
                    comboBox = missileLoadoutComboBox13;
                    importIndex = 21;
                    break;

                case 14:
                    comboBox = missileLoadoutComboBox14;
                    importIndex = 22;
                    break;

                case 15:
                    comboBox = missileLoadoutComboBox15;
                    importIndex = 23;
                    break;

                case 16:
                    comboBox = missileLoadoutComboBox16;
                    importIndex = 24;
                    break;

                case 17:
                    comboBox = missileLoadoutComboBox17;
                    importIndex = 25;
                    break;

                case 18:
                    comboBox = missileLoadoutComboBox18;
                    importIndex = 26;
                    break;

                case 19:
                    comboBox = missileLoadoutComboBox19;
                    importIndex = 27;
                    break;

                case 20:
                    comboBox = missileLoadoutComboBox20;
                    importIndex = 28;
                    break;

                case 21:
                    comboBox = missileLoadoutComboBox21;
                    importIndex = 29;
                    break;

                case 22:
                    comboBox = missileLoadoutComboBox22;
                    importIndex = 30;
                    break;

                case 23:
                    comboBox = missileLoadoutComboBox23;
                    importIndex = 31;
                    break;

                case 24:
                    comboBox = missileLoadoutComboBox24;
                    importIndex = 32;
                    break;

                case 25:
                    comboBox = missileLoadoutComboBox25;
                    importIndex = 33;
                    break;
            }

            switch (import[importIndex])
            {
                case "":
                    comboBox.Text = ":: None ::";
                    break;

                case "1":
                    comboBox.Text = "P80 Sidewinder";
                    break;

                case "2":
                    comboBox.Text = "KL760 Homing";
                    break;

                case "3":
                    comboBox.Text = "LV111 Intelligent";
                    break;

                case "4":
                    comboBox.Text = "NN500 Fleet";
                    break;

                case "5":
                    comboBox.Text = "NN550 Fleet";
                    break;

                case "6":
                    comboBox.Text = "Imperial MO89 Lord";
                    break;

                case "7":
                    comboBox.Text = "Imperial G-7 Smartwinder";
                    break;

                case "8":
                    comboBox.Text = "Imperial A/50 Pogo";
                    break;

                case "9":
                    comboBox.Text = "Imperial D/70 Havar";
                    break;

                case "10":
                    comboBox.Text = "Imperial Elite Mk.I";
                    break;

                case "11":
                    comboBox.Text = "Imperial Elite Mk.II";
                    break;

                case "12":
                    comboBox.Text = "King Relon";
                    break;

                case "13":
                    comboBox.Text = "King Kraak";
                    break;

                case "14":
                    comboBox.Text = "Royal Redeemer";
                    break;
            }
        }

        private void parseArmorID(ref string[] import)
        {
            //Importing Array Index 34!

            switch (import[34])
            {
                case "":
                    armorComboBox.Text = ":: None ::";
                    break;

                case "1":
                    armorComboBox.Text = "Titanium (x1)";
                    break;

                case "2":
                    armorComboBox.Text = "Tritanium (x2)";
                    break;

                case "3":
                    armorComboBox.Text = "Zortrium (x3)";
                    break;

                case "4":
                    armorComboBox.Text = "Neutronium (x4)";
                    break;

                case "5":
                    armorComboBox.Text = "Adamantium (x5)";
                    break;

                case "6":
                    armorComboBox.Text = "Ebidium (x6)";
                    break;

                case "7":
                    armorComboBox.Text = "Worm-Slime (x2)";
                    break;

                case "8":
                    armorComboBox.Text = "Mykoplasmic (x3)";
                    break;

                case "9":
                    armorComboBox.Text = "Mutagen (x4)";
                    break;

                case "10":
                    armorComboBox.Text = "Genotrope (x5)";
                    break;

                case "11":
                    armorComboBox.Text = "Fermion (x2)";
                    break;

                case "12":
                    armorComboBox.Text = "Boson (x3)";
                    break;

                case "13":
                    armorComboBox.Text = "Positron (x4)";
                    break;

                case "14":
                    armorComboBox.Text = "Anti-Neutrino (x5)";
                    break;

                case "15":
                    armorComboBox.Text = "Pardus I";
                    break;

                case "16":
                    armorComboBox.Text = "Pardus II";
                    break;

                case "17":
                    armorComboBox.Text = "Pardus III";
                    break;

                case "18":
                    armorComboBox.Text = "Pardus IV";
                    break;

                case "19":
                    armorComboBox.Text = "Pardus V";
                    break;

                case "20":
                    armorComboBox.Text = "Pardus VI";
                    break;
            }
        }

        private void parseShieldID(ref string[] import)
        {
            switch (import[35])
            {
                case "":
                    shieldSelectComboBox.Text = ":: None ::";
                    break;

                case "1":
                    shieldSelectComboBox.Text = "Small";
                    break;

                case "2":
                    shieldSelectComboBox.Text = "Standard";
                    break;

                case "3":
                    shieldSelectComboBox.Text = "Medium";
                    break;

                case "4":
                    shieldSelectComboBox.Text = "Large";
                    break;

                case "5":
                    shieldSelectComboBox.Text = "Tiny";
                    break;

                case "6":
                    shieldSelectComboBox.Text = "Q-Small";
                    break;

                case "7":
                    shieldSelectComboBox.Text = "Q-Standard";
                    break;

                case "8":
                    shieldSelectComboBox.Text = "Q-Medium";
                    break;

                case "9":
                    shieldSelectComboBox.Text = "Q-Large";
                    break;

                case "10":
                    shieldSelectComboBox.Text = "Huge";
                    break;

                case "11":
                    shieldSelectComboBox.Text = "Q-Huge";
                    break;

                case "12":
                    shieldSelectComboBox.Text = "L-Huge";
                    break;

                case "13":
                    shieldSelectComboBox.Text = "LQ-Large";
                    break;

                case "14":
                    shieldSelectComboBox.Text = "LQ-Huge";
                    break;
            }
        }

        private void parseDriveID(ref string[] import)
        {
            switch (import[36])
            {
                case "":
                    driveSelectBox.Text = ":: None ::";
                    break;

                case "1":
                    driveSelectBox.Text = "Nuclear Drive";
                    break;

                case "2":
                    driveSelectBox.Text = "Fusion Drive";
                    break;

                case "3":
                    driveSelectBox.Text = "Ion Drive";
                    break;

                case "4":
                    driveSelectBox.Text = "Antimatter Drive";
                    break;

                case "5":
                    driveSelectBox.Text = "Hyper Drive";
                    break;

                case "6":
                    driveSelectBox.Text = "Interphased Drive";
                    break;

                case "7":
                    driveSelectBox.Text = "Enhanced Fusion Drive";
                    break;

                case "8":
                    driveSelectBox.Text = "Enhanced Antimatter Drive";
                    break;

                case "9":
                    driveSelectBox.Text = "Enhanced Interphased Drive";
                    break;
            }
        }
        #endregion

        private void pardusArmorRetryButton_Click(object sender, EventArgs e)
        {
            int modeStrength = 0;
            int armorStrength = GetArmorData(ref modeStrength);

            calculatePardusArmor(ref armorStrength);

            //Update Summary Page:
            updateSummaryPage();
        }

        private void exportToFSCTextBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (exportToFSCTextBox.Text == "Paste FSC code to import here!")
            {
#if MONO // Fix for MONO bug: https://bugzilla.novell.com/show_bug.cgi?id=621475
                exportToFSCTextBox.SelectionStart = 0;
#endif
                exportToFSCTextBox.Text = "";
            }
        }

        private void copyButton_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                Clipboard.SetDataObject(exportToFSCTextBox.Text, true);
            }
            catch (Exception)
            {
                error = true;
                MessageBox.Show("Copying to clipboard failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!error)
            {
                MessageBox.Show("Successfully copied FSC data to clipboard", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }

        #region online
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.drifter.herbal-jazz.net/tame/legal.php");
        }

        
        #endregion

        #region pilotBio
        private void raceSelectBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string imagepack = GetImagePackPath();

            factionAffGroupBox.Enabled = true;
            syndicateAffGroupBox.Enabled = true;
            sexGroupBox.Enabled = true;
            RaceDefaults.resetMinSkills();

            switch (raceSelectBox.Text)
            {
                case "Human":
                    // Set race-specific skill limits           
                    RaceDefaults.MIN_SKILL_HACKING = 15;
                    RaceDefaults.MIN_SKILL_ASTEROIDS = 15;
                    RaceDefaults.MIN_SKILL_FUEL = 15;

                    // Update race images
                    if (maleRadioButton.Checked == true)
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "human_64x64.jpg"));
                    }
                    else
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "human_64x64f.jpg"));
                    }
                    break;

                case "Keldon":
                    // Skills
                    RaceDefaults.MIN_SKILL_ENG = 15;
                    RaceDefaults.MIN_SKILL_CLOAK = 15;

                    //Images
                    if (maleRadioButton.Checked == true)
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "keldon_64x64.jpg"));
                    }
                    else
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "keldon_64x64f.jpg"));
                    }
                    break;

                case "Rashkir":
                    // Set Race-specific skill limts
                  
                    RaceDefaults.MIN_SKILL_MAN = 15;
                    RaceDefaults.MIN_SKILL_WEAP = 15;
                    RaceDefaults.MIN_SKILL_HA = 15;
                    RaceDefaults.MIN_SKILL_TAC = 20;

                    // Update image
                    if (maleRadioButton.Checked == true)
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "rashkir_64x64.jpg"));
                    }
                    else
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "rashkir_64x64f.jpg"));
                    }
                    break;

                case "Ska'ari":
                    // Skills
                    RaceDefaults.MIN_SKILL_ENERGY = 20;
                    RaceDefaults.MIN_SKILL_NEBULA = 20;

                    // Images
                    if (maleRadioButton.Checked == true)
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "skaari_64x64.jpg"));
                    }
                    else
                    {
                        pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("races", "skaari_64x64f.jpg"));
                    }
                    break;

                case "Cube":
                    pilotRaceImageBox.ImageLocation = Path.Combine(imagepack, Path.Combine("ships", "council_golden_cube.png"));
                    factionAffGroupBox.Enabled = false;
                    syndicateAffGroupBox.Enabled = false;
                    sexGroupBox.Enabled = false;
                    break;
            }
            // Take new minimum skills into account.
            refreshPilotTabSkills();
        }

        private void maleRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            raceSelectBox_SelectedIndexChanged(sender, e);
        }

        private void femaleRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            raceSelectBox_SelectedIndexChanged(sender, e);
        }

        private void fedRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButtonFlag)
            {
                if (tssRadioButton.Checked == true)
                {
                    tssRadioButton.Checked = false;
                }
            }
            CheckForRankRequirementConflicts();
        }

        private void empRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButtonFlag)
            {
                if (tssRadioButton.Checked == true)
                {
                    tssRadioButton.Checked = false;
                }
            }
            CheckForRankRequirementConflicts();

        }

        private void uniRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (!radioButtonFlag)
            {
                if (tssRadioButton.Checked == true)
                {
                    tssRadioButton.Checked = false;
                }
            }
            CheckForRankRequirementConflicts();
        }

        private void epsRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            CheckForRankRequirementConflicts();
        }

        private void neuSyndRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            CheckForRankRequirementConflicts();
        }

        private void neuRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            CheckForRankRequirementConflicts();
        }

        private void tssRadioButton_CheckedChanged(object sender, EventArgs e)
        {

            if (tssRadioButton.Checked == true)
            {
                radioButtonFlag = true;

                if (fedRadioButton.Checked == true)
                {
                    fedRadioButton.Checked = false;
                }
                if (empRadioButton.Checked == true)
                {
                    empRadioButton.Checked = false;
                }
                if (uniRadioButton.Checked == true)
                {
                    uniRadioButton.Checked = false;
                }
                radioButtonFlag = false;
            }
        }

        private void defensiveCombatComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (defensiveCombatComboBox.Text != "None")
            {
                offensiveCombatComboBox.Text = "None";
                offensiveCombatComboBox.Enabled = false;
            }
            else
            {
                offensiveCombatComboBox.Enabled = true;
            }
            applyBoosts();
        }

        private void offensiveCombatBomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (offensiveCombatComboBox.Text != "None")
            {
                defensiveCombatComboBox.Text = "None";
                defensiveCombatComboBox.Enabled = false;
            }
            else
            {
                defensiveCombatComboBox.Enabled = true;
            }
            applyBoosts();
        }


        private void importSkillsButton_Click(object sender, EventArgs e)
        {
            string[] textSplit;
            string[] Skills = { "Tactics:", "Hit accuracy:", "Maneuver:", "Weaponry:", "Engineering:", "Asteroid mining:", "Energy collecting:", "Gas collecting:", "Fuel collecting:", "Hacking:", "Cloaking:" };
            string skillValue;
            char tab = '\u0009';
            TextBox skillBox = null;
            int i, j;


            textSplit = ieTextBox.Text.Split('|');
            if (textSplit[0] == "FSC4pilot")
            {
                try
                {
                    baseTACTextBox.Text = textSplit[1].Remove(0, 4);
                    baseHATextBox.Text = textSplit[2].Remove(0, 3);
                    baseMANTextBox.Text = textSplit[3].Remove(0, 4);
                    baseWEAPTextBox.Text = textSplit[4].Remove(0, 5);
                    baseENGTextBox.Text = textSplit[5].Remove(0, 4);
                }
                catch (Exception)
                {
                    MessageBox.Show("Sorry, something went wrong - (FSC Import)");
                }
            }
            else
            {
                try
                {
                    for (i = 0; i < Skills.Length; i++)
                    {
                        textSplit = ieTextBox.Text.Split(tab);

                        for (j = 0; j < textSplit.Length; j++)
                        {
                            if (textSplit[j].Contains(Skills[i]))
                            {
                                skillBox = findSkillBox(Skills[i]);
                                skillValue = textSplit[j + 1];
                                skillBox.Text = skillValue;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Sorry, something went wrong - (Overview Import)");
                }
            }

            refreshPilotTabSkills();

        }

        private void exportSkillsButton_Click(object sender, EventArgs e)
        {
            ieTextBox.Text = "";
            string skillsString;

            skillsString = "FSC4pilot" + "|tac:" + baseTACTextBox.Text + "|HA:" + baseHATextBox.Text + "|man:" + baseMANTextBox.Text + "|weap:" + baseWEAPTextBox.Text + "|eng:" + baseENGTextBox.Text;

            ieTextBox.Text = skillsString;

        }

        private TextBox findSkillBox(string inputString)
        {
            TextBox box = null;

            switch (inputString)
            {
                case "Asteroid mining:":
                    box = baseASTTextBox;
                    break;

                case "Energy collecting:":
                    box = baseENETextBox;
                    break;


                case "Gas collecting:":
                    box = baseNEBTextBox;
                    break;

                case "Fuel collecting:":
                    box = baseFUETextBox;
                    break;

                case "Tactics:":
                    box = baseTACTextBox;
                    break;

                case "Hit accuracy:":
                    box = baseHATextBox;
                    break;

                case "Maneuver:":
                    box = baseMANTextBox;
                    break;

                case "Weaponry:":
                    box = baseWEAPTextBox;
                    break;

                case "Engineering:":
                    box = baseENGTextBox;
                    break;

                case "Cloaking:":
                    box = baseCLOTextBox;
                    break;

                case "Hacking:":
                    box = baseHACKTextBox;
                    break;
            }
            return box;
        }

        private void clearSkillImportTextBox_Click(object sender, EventArgs e)
        {
            ieTextBox.Text = "";
        }

        private void ieTextBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (ieTextBox.Text == "Paste Here!")
            {
#if MONO // Fix for MONO bug: https://bugzilla.novell.com/show_bug.cgi?id=621475
                ieTextBox.SelectionStart = 0;
#endif
                ieTextBox.Text = "";
            }
        }

        private void orgWeapSpecComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateAllGuns();
        }

        private void cWeapSpecLevelComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateAllGuns();
        }

        private void emWeapSpecComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateAllGuns();
        }

        private void refreshButton_Click(object sender, EventArgs e)
        {
            refreshPilotTabSkills();
        }

        private void refreshPilotTabSkills()
        {

            baseASTTextBox.ForeColor = Color.Black;
            baseENETextBox.ForeColor = Color.Black;
            baseNEBTextBox.ForeColor = Color.Black;
            baseFUETextBox.ForeColor = Color.Black;

            baseTACTextBox.ForeColor = Color.Black;
            baseHATextBox.ForeColor = Color.Black;
            baseMANTextBox.ForeColor = Color.Black;
            baseWEAPTextBox.ForeColor = Color.Black;
            baseENGTextBox.ForeColor = Color.Black;

            baseCLOTextBox.ForeColor = Color.Black;
            baseHACKTextBox.ForeColor = Color.Black;

            #region racelimits
            // Try catch should avoid parse crashes. If the localisation fails for whatever reason.
            try {
                if (float.Parse(baseASTTextBox.Text) < RaceDefaults.MIN_SKILL_ASTEROIDS)
                {
                    baseASTTextBox.Text = RaceDefaults.MIN_SKILL_ASTEROIDS.ToString();
                    baseASTTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseENETextBox.Text) < RaceDefaults.MIN_SKILL_ENERGY)
                {
                    baseENETextBox.Text = RaceDefaults.MIN_SKILL_ENERGY.ToString();
                    baseENETextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseNEBTextBox.Text) < RaceDefaults.MIN_SKILL_NEBULA)
                {
                    baseNEBTextBox.Text = RaceDefaults.MIN_SKILL_NEBULA.ToString();
                    baseNEBTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseFUETextBox.Text) < RaceDefaults.MIN_SKILL_FUEL)
                {
                    baseFUETextBox.Text = RaceDefaults.MIN_SKILL_FUEL.ToString();
                    baseFUETextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseTACTextBox.Text) < RaceDefaults.MIN_SKILL_TAC)
                {
                    baseTACTextBox.Text = RaceDefaults.MIN_SKILL_TAC.ToString();
                    baseTACTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseHATextBox.Text) < RaceDefaults.MIN_SKILL_HA)
                {
                    baseHATextBox.Text = RaceDefaults.MIN_SKILL_HA.ToString();
                    baseHATextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseMANTextBox.Text) < RaceDefaults.MIN_SKILL_MAN)
                {
                    baseMANTextBox.Text = RaceDefaults.MIN_SKILL_MAN.ToString();
                    baseMANTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseWEAPTextBox.Text) < RaceDefaults.MIN_SKILL_WEAP)
                {
                    baseWEAPTextBox.Text = RaceDefaults.MIN_SKILL_WEAP.ToString();
                    baseWEAPTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseENGTextBox.Text) < RaceDefaults.MIN_SKILL_ENG)
                {
                    baseENGTextBox.Text = RaceDefaults.MIN_SKILL_ENG.ToString();
                    baseENGTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseCLOTextBox.Text) < RaceDefaults.MIN_SKILL_CLOAK)
                {
                    baseCLOTextBox.Text = RaceDefaults.MIN_SKILL_CLOAK.ToString();
                    baseCLOTextBox.ForeColor = Color.Green;
                }
                if (float.Parse(baseHACKTextBox.Text) < RaceDefaults.MIN_SKILL_HACKING)
                {
                    baseHACKTextBox.Text = RaceDefaults.MIN_SKILL_HACKING.ToString();
                    baseHACKTextBox.ForeColor = Color.Green;
                }           
            }
            catch(Exception){ }
            #endregion

            actualASTLabel.Text = baseASTTextBox.Text;
            actualENELabel.Text = baseENETextBox.Text;
            actualNEBLabel.Text = baseNEBTextBox.Text;
            actualFUELLabel.Text = baseFUETextBox.Text;

            actualTACLabel.Text = baseTACTextBox.Text;
            actualHALabel.Text = baseHATextBox.Text;
            actualMANLabel.Text = baseMANTextBox.Text;
            actualWEAPLabel.Text = baseWEAPTextBox.Text;
            actualENGLabel.Text = baseENGTextBox.Text;

            actualCLOLabel.Text = baseCLOTextBox.Text;
            actualHACKLabel.Text = baseHACKTextBox.Text;
            
            applyBoosts();
            
        }

        private void ieTextBox_TextChanged(object sender, EventArgs e)
        {
            if (ieTextBox.Text == "")
            {
                clearSkillImportTextBox.Enabled = false;
            }
            else
            {
                clearSkillImportTextBox.Enabled = true;
            }
        }

        private void hullFortComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int modeHull = 5;
            float shipHull = playerShip.GetShipData(ref modeHull, shipSelectBox.Text);

            if (hullFortComboBox.Text == "None")
            {
                effectiveHullLabel.Text = shipHull.ToString() + " (Effective)";
            }
            if (hullFortComboBox.Text == "Level 1")
            {
                effectiveHullLabel.Text = ((shipHull / 100) * 120) + " (Effective)";
            }
            if (hullFortComboBox.Text == "Level 2")
            {
                effectiveHullLabel.Text = ((shipHull / 100) * 140) + " (Effective)";
            }
        }

        private void shieldPoweringComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int modePoints = 0;
            int shieldPoints = ShipEquipment.GetShieldData(ref modePoints, shieldSelectComboBox.Text);

            if (shieldPoweringComboBox.Text == "None")
            {
                effectiveShieldLabel.Text = shieldPoints.ToString() + " (Effective)";
            }
            if (shieldPoweringComboBox.Text == "Level 1")
            {
                effectiveShieldLabel.Text = ((shieldPoints / 100) * 125) + " (Effective)";
            }
            if (shieldPoweringComboBox.Text == "Level 2")
            {
                effectiveShieldLabel.Text = ((shieldPoints / 100) * 150) + " (Effective)";
            }
        }

        private void agiBoostComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            applyBoosts();
        }

        private void applyBoosts()
        {
            float baseMAN = 0;
            float baseENG = 0;
            float baseWEAP = 0;
            float baseHA = 0;
            float baseCLO = 0;
            double baseAST = 0;
            double baseENE = 0;
            double baseNEB = 0;
            double baseFUE = 0;
            double baseTAC = 0;
            double baseHACK = 0;

            double actualAST = 0;
            double actualENE = 0;
            double actualNEB = 0;
            double actualFUE = 0;
            float actualMAN = 0;
            float actualENG = 0;
            float actualWEAP = 0;
            float actualHA = 0;
            float actualCLO = 0;
            double actualTAC = 0;
            double actualHACK = 0;

            float HAinCombat = 0;
            float MANinCombat = 0;
            float WeapinCombat = 0;
            float EnginCombat = 0;

            int i;

            try
            {
                baseMAN = float.Parse(baseMANTextBox.Text);
                baseENG = float.Parse(baseENGTextBox.Text);
                baseHA = float.Parse(baseHATextBox.Text);
                baseWEAP = float.Parse(baseWEAPTextBox.Text);
                baseCLO = float.Parse(baseCLOTextBox.Text);
                baseAST = double.Parse(baseASTTextBox.Text);
                baseNEB = double.Parse(baseNEBTextBox.Text);
                baseENE = double.Parse(baseENETextBox.Text);
                baseFUE = double.Parse(baseFUETextBox.Text);
                baseTAC = double.Parse(baseTACTextBox.Text);
                baseHACK = double.Parse(baseHACKTextBox.Text);
            }
            catch (Exception)
            {
                ErrorForm err = new ErrorForm(baseMANTextBox.Text, baseMANTextBox.Name.ToString(), "turning base skill from text into a number.");
                err.ShowDialog();
            }

            /* Set initial actual vlaues to match base values for maths */
            actualAST = baseAST;
            actualNEB = baseNEB;
            actualENE = baseENE;
            actualFUE = baseFUE;
            actualMAN = baseMAN;
            MANinCombat = baseMAN;
            actualENG = baseENG;
            EnginCombat = baseENG;
            actualWEAP = baseWEAP;
            WeapinCombat = baseWEAP;
            actualHA = baseHA;
            HAinCombat = baseHA;
            actualCLO = baseCLO;
            actualTAC = baseTAC;
            actualHACK = baseHACK;


            // Work out agi boost bonus.
            for (i = 1; i < 5; i++)
            {
                if (agiBoostComboBox.SelectedIndex == i)
                {
                    actualMAN = ((actualMAN / 100) * (100 + (i * 5)));
                    // actualMAN += (float) ((actualMAN / 100) * (i * 4.454));
                }
            }

            // Work out cloaking boost.
            for (i = 1; i < 5; i++)
            {
                if (cloakingBoostComboBox.SelectedIndex == i)
                {
                    actualCLO = ((actualCLO / 100) * (100 + (i * 10)));
                }
            }

            
            // ORDER: Crew/Agi Boost/DC-OC <--- WRONG is AB/CB FIRST.
            // Still need crew.            
            double bonus = 0;
            double currSkill = 0;
            int level = 0;
            int k;
            bool Secondary = false;
            try
            {
                for (k = 0; k< 5; k++)
                {
                    if (activeCrew[k, 0] == "Y")
                    {

                        if (activeCrew[k, 1] == "leg")
                        {
                            // First Effect
                            for (i = 0; i < 2; i++)
                            {
                                if (i == 1)
                                {
                                    Secondary = true;
                                }
                                switch (Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex))
                                {
                                    case 0:
                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualMAN = (float)(actualMAN + (actualMAN * bonus));
                                        break;

                                    case 1:
                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualAST = (actualAST + (actualAST * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualNEB = (actualNEB + (actualNEB * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualENE = (actualENE + (actualENE * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualFUE = (actualFUE + (actualFUE * bonus));
                                        break;

                                    case 2:
                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualTAC = (actualTAC + (actualTAC * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualHA = (float)(actualHA + (actualHA * bonus));
                                        break;

                                    case 3:
                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualENG = (float)(actualENG + (actualENG * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualWEAP = (float)(actualWEAP + (actualWEAP * bonus));
                                        break;

                                    case 4:
                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualCLO = (float)(actualCLO + (actualCLO * bonus));

                                        bonus = Crew.convertAbilityValueToBonusValue(Crew.GetLegCrewData(i, legendaryComboBox.SelectedIndex), Secondary);
                                        actualHACK = (actualHACK + (actualHACK * bonus));
                                        break;
                                }
                            }
                        }
                        // It's a normal crewwie!
                        else
                        {
                            // { active (Y/N), leg, name, cost, effect1, effect2, type, level};
                            // Determine level
                            level = int.Parse(activeCrew[k, 7]);

                            switch (activeCrew[k,6])
                            {
                                case "Navigator":
                                actualMAN += 1 + level;
                                break;

                                case "Gatherer":
                                actualAST += 0.5 * (1 + level);
                                actualENE += 0.5 * (1 + level);
                                actualNEB += 0.5 * (1 + level);
                                actualFUE += 0.5 * (1 + level);
                                break;

                                case "Tactician":
                                actualTAC += 0.5 * (1 + level);
                                actualHA += (float) (0.5 * (1 + level));
                                break;

                                case "Engineer":
                                actualENG += (float) (0.5 * (1 + level));
                                actualWEAP += (float) (0.5 * (1 + level));
                                break;

                                case "Hacker":
                                actualCLO += (float) (0.5 * (1 + level));
                                 actualHACK   += 0.5 * (1 + level);
                                 break;
                            }

                        }
                    }
                }


            }
            catch (Exception) { }
            //END CREW

           

           // In case DC / OC not selected - update in combat to plain actual value:
            MANinCombat = actualMAN;
            EnginCombat = actualENG;
            HAinCombat = actualHA;
            WeapinCombat = actualWEAP;

            //Work out DC
            if (defensiveCombatComboBox.Enabled == true)
            {
                if (defensiveCombatComboBox.Text != "None")
                {
                    for (i = 1; i < 4; i++)
                    {
                        if (defensiveCombatComboBox.SelectedIndex == i)
                        {
                            MANinCombat = ((actualMAN / 100) * (100 + (i * 10)));
                            EnginCombat = ((actualENG / 100) * (100 + (i * 10)));
                            HAinCombat = (actualHA / 100) * (60);
                            WeapinCombat = ((actualWEAP / 100) * 60);
                        }
                    }
                }
            }          
   

            // Work out OC
            if (offensiveCombatComboBox.Enabled == true)
            {
                if (offensiveCombatComboBox.Text != "None")
                {
                    for (i = 1; i < 4; i++)
                    {
                        if (offensiveCombatComboBox.SelectedIndex == i)
                        {
                            MANinCombat = ((actualMAN / 100) * 50);
                            EnginCombat = ((actualENG / 100) * 50);
                            HAinCombat = ((actualHA / 100) * (100 + (i * 15)));
                            WeapinCombat = ((actualWEAP / 100) * (100 + (i * 15)));
                        }
                    }
                }
            }

            // Bounds Checking
            if (actualMAN < 10)
            {
                actualMAN = 10;
            }
            if (actualTAC < 10)
            {
                actualTAC = 10;
            }
            if (actualENG < 10)
            {
                actualENG = 10;
            }
            if (actualWEAP < 10)
            {
                actualWEAP = 10;
            }
            if (actualHA < 10)
            {
                actualHA = 10;
            }
            if (HAinCombat < 10)
            {
                HAinCombat = 10;
            }
            if (EnginCombat < 10)
            {
                EnginCombat = 10;
            }
            if (WeapinCombat < 10)
            {
                WeapinCombat = 10;
            }
            if (MANinCombat < 10)
            {
                MANinCombat = 10;
            }

            // Change Colours
            //Man
            if (actualMAN == baseMAN)
            {
                actualMANLabel.ForeColor = Color.Black;
            }
            if (actualMAN > baseMAN)
            {
                actualMANLabel.ForeColor = Color.Green;
            }
            if (actualMAN < baseMAN)
            {
                actualMANLabel.ForeColor = Color.Red;
            }           
            if (MANinCombat == baseMAN)
            {
                ManInCombatLabel.ForeColor = Color.Black;
            }
            if (MANinCombat > baseMAN)
            {
                ManInCombatLabel.ForeColor = Color.Green;
            }
            if (MANinCombat < baseMAN)
            {
                ManInCombatLabel.ForeColor = Color.Red;
            }
            //Eng
            if (actualENG == baseENG)
            {
                actualENGLabel.ForeColor = Color.Black;
            }
            if (actualENG > baseENG)
            {
                actualENGLabel.ForeColor = Color.Green;
            }
            if (actualENG < baseENG)
            {
                actualENGLabel.ForeColor = Color.Red;
            }
            if (EnginCombat == baseENG)
            {
                EngInCombatLabel.ForeColor = Color.Black;
            }
            if (EnginCombat > baseENG)
            {
                EngInCombatLabel.ForeColor = Color.Green;
            }
            if (EnginCombat < baseENG)
            {
                EngInCombatLabel.ForeColor = Color.Red;
            }
            // HA
            if (actualHA == baseHA)
            {
                actualHALabel.ForeColor = Color.Black;
            }
            if (actualHA > baseHA)
            {
                actualHALabel.ForeColor = Color.Green;
            }
            if (actualHA < baseHA)
            {
                actualHALabel.ForeColor = Color.Red;
            }
            if (HAinCombat == baseHA)
            {
                HAInCombatLabel.ForeColor = Color.Black;
            }
            if (HAinCombat > baseHA)
            {
                HAInCombatLabel.ForeColor = Color.Green;
            }
            if (HAinCombat < baseHA)
            {
                HAInCombatLabel.ForeColor = Color.Red;
            }
            // Weap
            if (actualWEAP == baseWEAP)
            {
                actualWEAPLabel.ForeColor = Color.Black;
            }
            if (actualWEAP > baseWEAP)
            {
                actualWEAPLabel.ForeColor = Color.Green;
            }
            if (actualWEAP < baseWEAP)
            {
                actualWEAPLabel.ForeColor = Color.Red;
            }
            if (WeapinCombat == baseWEAP)
            {
                WeapInCombatLabel.ForeColor = Color.Black;
            }
            if (WeapinCombat > baseWEAP)
            {
                WeapInCombatLabel.ForeColor = Color.Green;
            }
            if (WeapinCombat < baseWEAP)
            {
                WeapInCombatLabel.ForeColor = Color.Red;
            }
            // Cloak
            if (actualCLO == baseCLO)
            {
                actualCLOLabel.ForeColor = Color.Black;
            }
            if (actualCLO > baseCLO)
            {
                actualCLOLabel.ForeColor = Color.Green;
            }
            if (actualCLO < baseCLO)
            {
                actualCLOLabel.ForeColor = Color.Red;
            }
            // TAC
            if (actualTAC == baseTAC)
            {
                actualTACLabel.ForeColor = Color.Black;
            }
            if (actualTAC > baseTAC)
            {
                actualTACLabel.ForeColor = Color.Green;
            }
            if (actualTAC < baseTAC)
            {
                actualTACLabel.ForeColor = Color.Red;
            }
            // HAck
            if (actualHACK == baseHACK)
            {
                actualHACKLabel.ForeColor = Color.Black;
            }
            if (actualHACK > baseHACK)
            {
                actualHACKLabel.ForeColor = Color.Green;
            }
            if (actualHACK < baseHACK)
            {
                actualHACKLabel.ForeColor = Color.Red;
            }
            // ASTEROIDS
            if (actualAST == baseAST)
            {
                actualASTLabel.ForeColor = Color.Black;
            }
            if (actualAST > baseAST)
            {
                actualASTLabel.ForeColor = Color.Green;
            }
            if (actualAST < baseAST)
            {
                actualASTLabel.ForeColor = Color.Red;
            }
            // NEB
            if (actualNEB == baseNEB)
            {
                actualNEBLabel.ForeColor = Color.Black;
            }
            if (actualNEB > baseNEB)
            {
                actualNEBLabel.ForeColor = Color.Green;
            }
            // Energy
            if (actualENE == baseENE)
            {
                actualENELabel.ForeColor = Color.Black;
            }
            if (actualENE > baseENE)
            {
                actualENELabel.ForeColor = Color.Green;
            }
            // Space
            if (actualFUE == baseFUE)
            {
                actualFUELLabel.ForeColor = Color.Black;
            }
            if (actualFUE > baseFUE)
            {
                actualFUELLabel.ForeColor = Color.Green;
            }
            

            // Update Labels.
            actualMANLabel.Text = actualMAN.ToString("N2");
            actualTACLabel.Text = actualTAC.ToString("N2");
            actualENGLabel.Text = actualENG.ToString("N2");
            actualHALabel.Text = actualHA.ToString("N2");
            actualWEAPLabel.Text = actualWEAP.ToString("N2");
            actualCLOLabel.Text = actualCLO.ToString("N2");
            HAInCombatLabel.Text = HAinCombat.ToString("N2");
            ManInCombatLabel.Text = MANinCombat.ToString("N2");
            WeapInCombatLabel.Text = WeapinCombat.ToString("N2");
            EngInCombatLabel.Text = EnginCombat.ToString("N2");

            actualHACKLabel.Text = actualHACK.ToString("N2");
            actualNEBLabel.Text = actualNEB.ToString("N2");
            actualENELabel.Text = actualENE.ToString("N2");
            actualFUELLabel.Text = actualFUE.ToString("N2");
            actualASTLabel.Text = actualAST.ToString("N2");
        }

        private void cloakingBoostComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            applyBoosts();
        }

        #endregion

        #region multipleUnis
        private void universeSelectComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            universe = universeSelectComboBox.Text.ToLower();
            SetTameDirectoryPath();

            if (startup != true)
            {
                if (File.Exists(shipFile))
                {
                    loadShipFromXML();
                }
                if (File.Exists(pilotFile))
                {
                    loadPilotFromXML();
                }
                if (File.Exists(crewFile))
                {
                    loadCrewFromXML();
                }
            }


        }
        #endregion

        private void delUniverseButton_Click(object sender, EventArgs e)
        {
            DialogResult deleteAllLocalDataDialogResult = MessageBox.Show("Doing this will permanently delete this universe's data, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deleteAllLocalDataDialogResult == DialogResult.Yes)
            {
                try
                {
                    // Need "true" to avoid IO exception - deletes all files and subdirectories. 
                    if (File.Exists(shipFile))
                    {
                        File.Delete(shipFile);
                    }
                    if (File.Exists(pilotFile))
                    {
                        File.Delete(pilotFile);
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Unable to locate files for this universe - Contact Pigeon in Pegasus");
                }
                updateUsedDiskSpace();
            }
        }

        private void copySkillsButton_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                Clipboard.SetDataObject(ieTextBox.Text, true);
            }
            catch (Exception)
            {
                error = true;
                MessageBox.Show("Copying to clipboard failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!error)
            {
                MessageBox.Show("Successfully copied FSC data to clipboard", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        #region tools
        private void showDamageCalcButton_Click(object sender, EventArgs e)
        {
            int gunspace = freeSpaceRequiredForGuns();
            int freeSpace = (calculateTotalLoadoutSpace() - gunspace);
            int modeTankSize = 2;
            int tankSize = ShipEquipment.GetDriveData(ref modeTankSize, driveSelectBox.Text);
            string resultGuns = "";
            string[] gunNameArray = { "", "", "", "", "" };
            ComboBox[] Guncombos = { gunLoadoutComboBox1, gunLoadoutComboBox2, gunLoadoutComboBox3, gunLoadoutComboBox4, gunLoadoutComboBox5 };
            int i;

            if ((shipSelectBox.Text != "") && (shipSelectBox.Text != ":: Select Ship ::") && (shipSelectBox.Text != "Neutral Ships") && (shipSelectBox.Text != "Federation Ships") && (shipSelectBox.Text != "Empire Ships") && (shipSelectBox.Text != "Union Ships") && (shipSelectBox.Text != "EPS Ships") && (shipSelectBox.Text != "TSS Ships"))
            {
                GunSetupAdvisor damageCalc = new GunSetupAdvisor(shipSelectBox.Text, freeSpace, orgWeapSpecComboBox.SelectedIndex, emWeapSpecComboBox.SelectedIndex, cWeapSpecLevelComboBox.SelectedIndex, tankSize);
                damageCalc.ShowDialog();

                resultGuns = damageCalc.Result;
                if (resultGuns != null)
                {
                    gunNameArray = resultGuns.Split('|');

                    for (i = 0; i < 5; i++)
                    {
                        if (Guncombos[i].Enabled == true)
                        {
                            Guncombos[i].Text = gunNameArray[i];
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a ship from the designer tab.", "Error");
            }
        }
        #endregion

        private void loadSmaatWindowButton_Click(object sender, EventArgs e)
        {
            string[] gunsArray = { gunLoadoutComboBox1.Text, gunLoadoutComboBox2.Text, gunLoadoutComboBox3.Text, gunLoadoutComboBox4.Text, gunLoadoutComboBox5.Text };
            CombatSimForm smaatForm = new CombatSimForm(shipSelectBox.Text, shieldSelectComboBox.Text, armorComboBox.Text, hullFortComboBox.SelectedIndex, shieldPoweringComboBox.SelectedIndex, gunsArray, orgWeapSpecComboBox.SelectedIndex, emWeapSpecComboBox.SelectedIndex, cWeapSpecLevelComboBox.SelectedIndex);
            smaatForm.ShowDialog();
        }

        private void MainForm_Paint(object sender, PaintEventArgs e)
        {
            // Repaint form after control is removed.
            ScreenRefresh();
            DrawArmorPieCharts();
        }

        private void clearFSCImportBox_Click(object sender, EventArgs e)
        {
            exportToFSCTextBox.Text = "";
        }

        private void disablePieChartAACheckBox_CheckedChanged(object sender, EventArgs e)
        {
            unsavedChanges = true;
        }

        #region crew     
   
        private void useLegendaryCrewMemberCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (useLegendaryCrewMemberCheckBox.Checked == true)
            {
                legendaryComboBox.Visible = true;
                normalCrewComboxBox1.Visible = false;
                crewSexGroupBox1.Visible = false;
                secondaryProfessionLabel.Visible = true;
                primaryProfessionIndicatorlabel.Visible = true;
                SecondaryProfessionIndicatorLabel.Visible = true;
                legendaryReputationLabel.Visible = true;
                crewEffect2Label1.Visible = true;
                effect2Label1.Visible = true;
                updateCrewImages(0, 0, 0);

                crewNameSubtitleTextBox.ReadOnly = true;
                crewInitialCostTextBox1.ReadOnly = true;
                dailyCosttextBox1.ReadOnly = true;

                // Change the crew area to match legendaries.
                crewNameSubtitleLabel.Text = "Title:";
                primaryProfessionLabel.Text = "Primary:";
                secondaryProfessionLabel.Text = "Secondary:";
                crewNameSubtitleTextBox.Text = Crew.convertLegendaryNameToSubtitle(legendaryComboBox.SelectedIndex);
                legendaryReputationLabel.Text = Crew.convertLegendaryNameToRespectedStatus(legendaryComboBox.SelectedIndex);

                if (legendaryComboBox.SelectedIndex != -1)
                {
                    primaryProfessionIndicatorlabel.Text = Crew.convertAbilityValueToString(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex));
                    SecondaryProfessionIndicatorLabel.Text = Crew.convertAbilityValueToString(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex));
                    crewInitialCostTextBox1.Text = Crew.GetLegCrewData(2, legendaryComboBox.SelectedIndex).ToString("N");
                    dailyCosttextBox1.Text = Crew.GetLegCrewData(3, legendaryComboBox.SelectedIndex).ToString("N");
                    toolTip1.SetToolTip(crewPrimaryProfessionInfo1, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex)));
                    toolTip1.SetToolTip(crewSecondaryProfessionInfo2, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex)));
                    toolTip1.SetToolTip(primaryProfessionIndicatorlabel, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex)));
                    toolTip1.SetToolTip(SecondaryProfessionIndicatorLabel, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex)));
                    crewEffect1Label1.Text = Crew.convertAbilityValueToBonus(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex), false, true);
                    crewEffect2Label1.Text = Crew.convertAbilityValueToBonus(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex), true, true);

                }
                else
                {
                    primaryProfessionIndicatorlabel.Text = "N/A";
                    SecondaryProfessionIndicatorLabel.Text = "N/A";
                    crewInitialCostTextBox1.Text = "N/A";
                    dailyCosttextBox1.Text = "N/A";
                    crewEffect1Label1.Text = "N/A";
                    crewEffect2Label1.Text = "N/A";
                }

                switch (legendaryReputationLabel.Text)
                {
                    case "Neutral":
                        legendaryReputationLabel.ForeColor = Color.Gray;
                        break;

                    case "Despised":
                        legendaryReputationLabel.ForeColor = Color.Red;
                        break;

                    case "Respected":
                        legendaryReputationLabel.ForeColor = Color.Green;
                        break;

                    default:
                        legendaryReputationLabel.ForeColor = Color.Black;
                        break;
                }

                crewProfessionBox1.Visible = false;
                crewLevelBox1.Visible = false;

                crewPrimaryProfessionInfo1.Visible = true;
                crewSecondaryProfessionInfo2.Visible = true;

            }
            else
            {
                legendaryComboBox.Visible = false;
                normalCrewComboxBox1.Visible = true;
                crewSexGroupBox1.Visible = true;
                updateCrewImages(0, 1, 0);

                // Change the crew area to match normal crew.
                crewNameSubtitleLabel.Text = "Name:";
                crewNameSubtitleTextBox.ReadOnly = false;
                crewNameSubtitleTextBox.Text = "";
                primaryProfessionLabel.Text = "Profession:";
                secondaryProfessionLabel.Text = "Level:";
                primaryProfessionIndicatorlabel.Text = "";
                primaryProfessionIndicatorlabel.Visible = false;
                SecondaryProfessionIndicatorLabel.Visible = false;
                legendaryReputationLabel.Visible = false;
                crewProfessionBox1.Visible = true;
                crewLevelBox1.Visible = true;
                crewPrimaryProfessionInfo1.Visible = false;
                crewSecondaryProfessionInfo2.Visible = false;
                crewInitialCostTextBox1.Text = "";
                dailyCosttextBox1.Text = "";
                crewEffect1Label1.Text = "";
                crewEffect2Label1.Text = "";
                crewEffect2Label1.Visible = false;
                effect2Label1.Visible = false;
                crewInitialCostTextBox1.ReadOnly = false;
                dailyCosttextBox1.ReadOnly = false;
            }
        }

        private void legendaryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Update Displayed Data For Legendary:
            crewNameSubtitleTextBox.Text = Crew.convertLegendaryNameToSubtitle(legendaryComboBox.SelectedIndex);
            legendaryReputationLabel.Text = Crew.convertLegendaryNameToRespectedStatus(legendaryComboBox.SelectedIndex);
            if (legendaryComboBox.SelectedIndex != -1)
            {
                primaryProfessionIndicatorlabel.Text = Crew.convertAbilityValueToString(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex));
                SecondaryProfessionIndicatorLabel.Text = Crew.convertAbilityValueToString(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex));
                toolTip1.SetToolTip(primaryProfessionIndicatorlabel, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex)));
                toolTip1.SetToolTip(SecondaryProfessionIndicatorLabel, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex)));
                toolTip1.SetToolTip(crewPrimaryProfessionInfo1, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex)));
                toolTip1.SetToolTip(crewSecondaryProfessionInfo2, Crew.convertAbilityValueToDescription(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex)));
                crewInitialCostTextBox1.Text = Crew.GetLegCrewData(2, legendaryComboBox.SelectedIndex).ToString("N0");
                dailyCosttextBox1.Text = Crew.GetLegCrewData(3, legendaryComboBox.SelectedIndex).ToString("N0");

                crewEffect1Label1.Text = Crew.convertAbilityValueToBonus(Crew.GetLegCrewData(0, legendaryComboBox.SelectedIndex), false, true);
                crewEffect2Label1.Text = Crew.convertAbilityValueToBonus(Crew.GetLegCrewData(1, legendaryComboBox.SelectedIndex), true, true);


                if (crewInitialCostTextBox1.Text == "-1")
                {
                    crewInitialCostTextBox1.Text = "N/A";
                    dailyCosttextBox1.Text = "N/A";
                }
            }
            else
            {
                primaryProfessionIndicatorlabel.Text = "N/A";
                SecondaryProfessionIndicatorLabel.Text = "N/A";
                crewInitialCostTextBox1.Text = "N/A";
                dailyCosttextBox1.Text = "N/A";
                crewEffect1Label1.Text = "N/A";
                crewEffect2Label1.Text = "N/A";
            }


            updateCrewImages(0, 0, 0);

            switch (legendaryReputationLabel.Text)
            {
                case "Neutral":
                    legendaryReputationLabel.ForeColor = Color.Gray;
                    break;

                case "Despised":
                    legendaryReputationLabel.ForeColor = Color.Red;
                    break;

                case "Respected":
                    legendaryReputationLabel.ForeColor = Color.Green;
                    break;

                default:
                    legendaryReputationLabel.ForeColor = Color.Black;
                    break;
            }
        }

        private void updateCrewImages(int crewImageBox, int comboBox, int crewBox)
        {
            PictureBox[] boxes = { crewMemberPictureBox1, crewImagePicutreBox, crewMemberPictureBox2, crewMemberPictureBox3, crewMemberPictureBox4 };
            ComboBox[] combos = { legendaryComboBox, normalCrewComboxBox1, normalCrewComboxBox2, normalCrewComboxBox3, normalCrewComboxBox4 };
            RadioButton[] maleRads = { crewMaleRadioButton1, crewMaleRadioButton2, crewMaleRadioButton3, crewMaleRadioButton4 };

            imagePackPath = GetImagePackPath();

            boxes[crewImageBox].ImageLocation = null;
            boxes[crewImageBox].Image = null;

            if (crewBox < 1)
            {
                if (useLegendaryCrewMemberCheckBox.Checked == true)
                {
                    if ((legendaryComboBox.Text == ":: None ::") || (legendaryComboBox.Text == ""))
                    {
                        boxes[crewImageBox].Image = Tame.Properties.Resources.none_64x64;
                    }
                    else
                    {
                        boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("crew", legendaryComboBox.Text.ToLower().Replace(' ', '_') + ".jpg"));
                    }
                }
                else
                {
                    switch (combos[comboBox].Text)
                    {
                        case "Human":
                            if (maleRads[crewBox].Checked == true)
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "human_64x64.jpg"));
                            }
                            else
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "human_64x64f.jpg"));
                            }
                            break;

                        case "Keldon":
                            if (maleRads[crewBox].Checked == true)
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "keldon_64x64.jpg"));
                            }
                            else
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "keldon_64x64f.jpg"));
                            }
                            break;

                        case "Rashkir":
                            if (maleRads[crewBox].Checked == true)
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "rashkir_64x64.jpg"));
                            }
                            else
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "rashkir_64x64f.jpg"));
                            }
                            break;

                        case "Ska'ari":
                            if (maleRads[crewBox].Checked == true)
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "skaari_64x64.jpg"));
                            }
                            else
                            {
                                boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "skaari_64x64f.jpg"));
                            }
                            break;

                        default:
                            boxes[crewImageBox].Image = Tame.Properties.Resources.none_64x64;
                            break;
                    }
                }
            }
            else
            {
                switch (combos[comboBox].Text)
                {
                    case "Human":
                        if (maleRads[crewBox].Checked == true)
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "human_64x64.jpg"));
                        }
                        else
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "human_64x64f.jpg"));
                        }
                        break;

                    case "Keldon":
                        if (maleRads[crewBox].Checked == true)
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "keldon_64x64.jpg"));
                        }
                        else
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "keldon_64x64f.jpg"));
                        }
                        break;

                    case "Rashkir":
                        if (maleRads[crewBox].Checked == true)
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "rashkir_64x64.jpg"));
                        }
                        else
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "rashkir_64x64f.jpg"));
                        }
                        break;

                    case "Ska'ari":
                        if (maleRads[crewBox].Checked == true)
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "skaari_64x64.jpg"));
                        }
                        else
                        {
                            boxes[crewImageBox].ImageLocation = Path.Combine(imagePackPath, Path.Combine("races", "skaari_64x64f.jpg"));
                        }
                        break;

                    default:
                        boxes[crewImageBox].Image = Tame.Properties.Resources.none_64x64;
                        break;
                }
            }
        }

        private void updateCrewViewer()
        {
            crewImagePicutreBox.Image = null;
            crewImagePicutreBox.ImageLocation = null;

            // No crew, hide the viewer data.
            if (activeCrewCount == 0)
            {
                crewObscuringPanel.Visible = true;
                crewViewerTitleLabel.Text = "No Crew!";
            }
            // We have crew, populate the viewer
            else
            {
                crewObscuringPanel.Visible = false;

                // { active (Y/N), leg, name, cost, effect1, effect2};

                if (activeCrew[crewViewerIndex, 0] == "Y")
                {
                    crewViewerTitleLabel.Text = string.Format("Crew Seat: {0} ({1}/{2})", activeCrew[crewViewerIndex, 2], crewViewerIndex + 1, availableCrewSeats);
                    crewViewerCostlabel.Text = "Cost: " + activeCrew[crewViewerIndex, 3];
                    crewviewerEffectLabel.Text = "Effect: " + activeCrew[crewViewerIndex, 4];

                    if (activeCrew[crewViewerIndex, 1] == "leg")
                    {
                        crewViewerEffectLabel2.Visible = true;
                        crewViewerEffectLabel2.Text = "Effect: " + activeCrew[crewViewerIndex, 5];
                        updateCrewImages(1, 0, 0);
                    }
                    else
                    {
                        crewViewerEffectLabel2.Visible = false;
                        updateCrewImages(1, crewViewerIndex + 1, crewViewerIndex);
                    }
                }
                else
                {
                    crewViewerEffectLabel2.Visible = false;
                    crewViewerTitleLabel.Text = string.Format("Seat Empty: ({0}/{1})", crewViewerIndex + 1, availableCrewSeats);
                    crewViewerCostlabel.Text = "";
                    crewviewerEffectLabel.Text = "";
                    crewImagePicutreBox.Image = Tame.Properties.Resources.none_64x64;
                }
            }
            applyBoosts();
        }


        private void crewForwardButton_Click(object sender, EventArgs e)
        {
            if (crewViewerIndex < availableCrewSeats - 1)
            {
                crewViewerIndex++;
            }
            else
            {
                crewViewerIndex = 0;
            }

            updateCrewViewer();
        }

        private void crewBackwardsButton_Click(object sender, EventArgs e)
        {
            if (crewViewerIndex > 0)
            {
                crewViewerIndex--;
            }
            else
            {
                crewViewerIndex = availableCrewSeats - 1;
            }

            updateCrewViewer();
        }

        private void normalCrewComboxBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewImages(0, 1, 0);
        }

        private void crewMaleRadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(0, 1, 0);
        }

        private void crewFemaleRadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(0, 1, 0);
        }

        private void jettisonCrewMember1_Click(object sender, EventArgs e)
        {
            bool error = false;
            bool punct = false;
            crewViewerIndex = 0;
            if (jettisonCrewMember1.Text == "Hire!")
            {
                if (useLegendaryCrewMemberCheckBox.Checked == true)
                {
                    if (legendaryComboBox.SelectedIndex == -1)
                    {
                        MessageBox.Show("Select a legendary crew member from the drop-down menu!", "Select Legendary Crew Member", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        error = true;
                    }
                }
                else
                {
                    if ((crewProfessionBox1.SelectedIndex == -1) || (crewLevelBox1.SelectedIndex == -1) || (normalCrewComboxBox1.SelectedIndex == -1))
                    {
                        MessageBox.Show("You need to fill in the crew details before hiring - please make sure you've entered the race, profession and level of your crew member", "Incomplete Crew Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        error = true;
                    }
                }
                if (error != true)
                {
                    useLegendaryCrewMemberCheckBox.Enabled = false;
                    if (activeCrewCount < availableCrewSeats)
                    {
                        activeCrewCount++;
                        
                        // Crew Active?
                        // { active (Y/N), leg, name, cost, effect1, effect2, type, level};
                        activeCrew[0, 0] = "Y";
                        if (useLegendaryCrewMemberCheckBox.Checked == true)
                        {
                            activeCrew[0, 1] = "leg";
                            activeCrew[0, 2] = legendaryComboBox.Text;
                            activeCrew[0, 5] = crewEffect2Label1.Text;
                            legendaryComboBox.Enabled = false;
                        }
                        else
                        {
                            activeCrew[0, 1] = "norm";
                            activeCrew[0, 2] = crewNameSubtitleLabel.Text;
                            normalCrewComboxBox1.Enabled = false;
                            crewMaleRadioButton1.Enabled = false;
                            crewFemaleRadioButton1.Enabled = false;
                            crewProfessionBox1.Enabled = false;
                            crewLevelBox1.Enabled = false;
                            crewNameSubtitleTextBox.Enabled = false;
                            crewInitialCostTextBox1.Enabled = false;
                            dailyCosttextBox1.Enabled = false;                            
                        }
                        activeCrew[0, 3] = dailyCosttextBox1.Text;
                        activeCrew[0, 4] = crewEffect1Label1.Text;
                        activeCrew[0, 6] = crewProfessionBox1.Text;
                        activeCrew[0, 7] = crewLevelBox1.Text;

                        jettisonCrewMember1.Text = "Jettison";
                        jettisonCrewMember1.Image = Tame.Properties.Resources.cancel_48;

                        if (dailyCosttextBox1.Text != "")
                        {                            
                            try
                            {
                                string dailyCost = "0";
                                if (dailyCosttextBox1.Text.Contains(","))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox1.Text, ",", "");
                                    punct = true;
                                }
                                else if (punct == false)
                                {
                                    dailyCost = dailyCosttextBox1.Text;
                                }
                                int dailyCostInt = int.Parse(dailyCost);
                                crewStatsLabel1.Text = string.Format("Monthly Cost: {1}{0}Yearly Cost: {2}{0}Cost After Death (est): {3}{0}", Environment.NewLine, (dailyCostInt * 30).ToString("N0"), (dailyCostInt * 365).ToString("N0"), (myMaths.Round(((double)dailyCostInt * 1.5), -3)).ToString("N0"));
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("The daily cost could not be turned into a number properly. Please make sure you've not got any letters or punctuation in the \"Daily Cost\" box.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("You can't hire this crew member. Your ship doesn't have enough crew seats left. Jettison another crew member, or select another ship to hire more crew", "Not Enough Crew Seats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (jettisonCrewMember1.Text == "Jettison")
            {
                string gender = "";
                if (crewMaleRadioButton1.Checked == true)
                {
                    gender = "him";
                }
                if (crewFemaleRadioButton1.Checked == true)
                {
                    gender = "her";
                }
                if (useLegendaryCrewMemberCheckBox.Checked == true)
                {
                    gender = "it";
                }
                DialogResult jettisonDialogResult = MessageBox.Show(string.Format("\"Oh please God no, not the airlock! You can pay me later, pay me later!\" {0}{0}Are you really going to throw {1} out of the airlock? (Only hired members will affect your skills)", Environment.NewLine, gender), "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (jettisonDialogResult == DialogResult.Yes)
                {

                    activeCrewCount--;
                    activeCrew[0, 0] = "N";
                    jettisonCrewMember1.Text = "Hire!";                    
                    jettisonCrewMember1.Image = Tame.Properties.Resources.add_48;
                    crewStatsLabel1.Text = "";
                    legendaryComboBox.Enabled = true;
                    crewProfessionBox1.Enabled = true;
                    crewLevelBox1.Enabled = true;
                    crewNameSubtitleTextBox.Enabled = true;
                    crewInitialCostTextBox1.Enabled = true;
                    dailyCosttextBox1.Enabled = true;
                    normalCrewComboxBox1.Enabled = true;
                    crewMaleRadioButton1.Enabled = true;
                    crewFemaleRadioButton1.Enabled = true;
                    useLegendaryCrewMemberCheckBox.Enabled = true;
                }
            }
            if (useLegendaryCrewMemberCheckBox.Checked == true)
            {
                updateCrewImages(1, 0, 0);
            }
            else
            {
                updateCrewImages(1, 1, 0);
            }
            updateCrewViewer();
            determineMovementCost();

        }

        private void updateCrewEffect(int crewMember)
        {
            Label[] textBoxes = { crewEffect1Label1, crewEffect1Label2, crewEffect1Label3, crewEffect1Label4 };
            ComboBox[] levelComboBoxes = { crewLevelBox1, crewLevelBox2, crewLevelBox3, crewLevelBox4 };
            ComboBox[] crewProffessions = { crewProfessionBox1, crewProfessionBox2, crewProfessionBox3, crewProfessionBox4 };

            levelComboBoxes[crewMember].Enabled = true;

            if ((levelComboBoxes[crewMember].SelectedIndex != -1) && (crewProffessions[crewMember].SelectedIndex != -1))
            {
                if (crewProffessions[crewMember].SelectedIndex == 0)
                {
                    //Navigator
                    textBoxes[crewMember].Text = "+" + (1 + (levelComboBoxes[crewMember].SelectedIndex + 1)).ToString() + " To MAN";
                }
                if (crewProffessions[crewMember].SelectedIndex == 1)
                {
                    //Gatherer
                    textBoxes[crewMember].Text = "+" + (0.5 * (1 + (levelComboBoxes[crewMember].SelectedIndex + 1))).ToString() + " To Collecting Skills";
                }
                if (crewProffessions[crewMember].SelectedIndex == 2)
                {
                    //Tactician
                    textBoxes[crewMember].Text = "+" + (0.5 * (1 + (levelComboBoxes[crewMember].SelectedIndex + 1))).ToString() + " To TAC & HA";
                }
                if (crewProffessions[crewMember].SelectedIndex == 3)
                {
                    //Engineer
                    textBoxes[crewMember].Text = "+" + (0.5 * (1 + (levelComboBoxes[crewMember].SelectedIndex + 1))).ToString() + " To ENG & WEAP";
                }
                if (crewProffessions[crewMember].SelectedIndex == 4)
                {
                    //Hacker
                    textBoxes[crewMember].Text = "+" + (0.5 * (1 + (levelComboBoxes[crewMember].SelectedIndex + 1))).ToString() + " To Cloaking & hacking";
                }
                if (crewProffessions[crewMember].SelectedIndex == 5)
                {
                    // Missile Tac
                    levelComboBoxes[crewMember].Enabled = false;
                    textBoxes[crewMember].Text = "+1 to Missile Int";
                }
            }

        }

        private void crewProfessionBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(0);
        }

        private void crewLevelBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(0);
        }

        private void normalCrewComboxBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewImages(2, 2, 1);
        }

        private void crewMaleRadioButton2_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(2, 2, 1);
        }

        private void crewFemaleRadioButton2_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(2, 2, 1);
        }

        private void crewProfessionBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(1);
        }

        private void crewLevelBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(1);
        }

        private void jettisonCrewMember2_Click(object sender, EventArgs e)
        {
            crewViewerIndex = 1;
            bool punct = false;
            if (jettisonCrewMember2.Text == "Hire!")
            {
                if ((crewProfessionBox2.SelectedIndex == -1) || (crewLevelBox2.SelectedIndex == -1) || (normalCrewComboxBox2.SelectedIndex == -1))
                {
                    MessageBox.Show("You need to fill in the crew details before hiring - please make sure you've entered the race, profession and level of your crew member", "Incomplete Crew Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (activeCrewCount < availableCrewSeats)
                    {
                        activeCrewCount++;

                        // Crew Active?
                        // { active (Y/N), leg, name, cost, effect1, effect2};
                        activeCrew[1, 0] = "Y";
                        activeCrew[1, 1] = "norm";
                        activeCrew[1, 2] = crewNameTextBox2.Text;
                        activeCrew[1, 3] = dailyCosttextBox2.Text;
                        activeCrew[1, 4] = crewEffect1Label2.Text;
                        activeCrew[1, 6] = crewProfessionBox2.Text;
                        activeCrew[1, 7] = crewLevelBox2.Text;

                        jettisonCrewMember2.Text = "Jettison";
                        jettisonCrewMember2.Image = Tame.Properties.Resources.cancel_48;

                        if (dailyCosttextBox2.Text != "")
                        {
                            try
                            {
                                string dailyCost = "0";
                                if (dailyCosttextBox2.Text.Contains(","))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox2.Text, ",", "");
                                    punct = true;
                                }
                                else if (dailyCosttextBox2.Text.Contains("."))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox2.Text, ".", "");
                                    punct = true;
                                }
                                else if (punct == false)
                                {
                                    dailyCost = dailyCosttextBox2.Text;
                                }
                                int dailyCostInt = int.Parse(dailyCost);

                                crewStatsLabel2.Text = string.Format("Monthly Cost: {1}{0}Yearly Cost: {2}{0}Cost After Death (est): {3}{0}", Environment.NewLine, (dailyCostInt * 30).ToString("N0"), (dailyCostInt * 365).ToString("N0"), (myMaths.Round(((double)dailyCostInt * 1.5), -3)).ToString("N0"));
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("The daily cost could not be turned into a number properly. Please make sure you've not got any letters or punctuation in the \"Daily Cost\" box.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }


                        crewProfessionBox2.Enabled = false;
                        crewLevelBox2.Enabled = false;
                        crewNameTextBox2.Enabled = false;
                        crewInitialCostTextBox2.Enabled = false;
                        dailyCosttextBox2.Enabled = false;
                        normalCrewComboxBox2.Enabled = false;
                        crewMaleRadioButton2.Enabled = false;
                        crewFemaleRadioButton2.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("You can't hire this crew member. Your ship doesn't have enough crew seats left. Jettison another crew member, or select another ship to hire more crew", "Not Enough Crew Seats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (jettisonCrewMember2.Text == "Jettison")
            {
                string gender = "";
                if (crewMaleRadioButton2.Checked == true)
                {
                    gender = "him";
                }
                if (crewFemaleRadioButton2.Checked == true)
                {
                    gender = "her";
                }
                DialogResult jettisonDialogResult = MessageBox.Show(string.Format("\"Oh please God no, not the airlock! You can pay me later, pay me later!\" {0}{0}Are you really going to throw {1} out of the airlock? (Only hired members will affect your skills)", Environment.NewLine, gender), "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (jettisonDialogResult == DialogResult.Yes)
                {
                    activeCrewCount--;
                    activeCrew[1, 0] = "N";
                    jettisonCrewMember2.Text = "Hire!";                    
                    jettisonCrewMember2.Image = Tame.Properties.Resources.add_48;
                    crewStatsLabel2.Text = "";
                    crewProfessionBox2.Enabled = true;
                    crewLevelBox2.Enabled = true;
                    crewNameTextBox2.Enabled = true;
                    crewInitialCostTextBox2.Enabled = true;
                    dailyCosttextBox2.Enabled = true;
                    normalCrewComboxBox2.Enabled = true;
                    crewMaleRadioButton2.Enabled = true;
                    crewFemaleRadioButton2.Enabled = true;
                }
            }

            updateCrewImages(2, 2, 1);
            updateCrewViewer();

        }

        private void normalCrewComboxBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewImages(3, 3, 2);
        }

        private void crewMaleRadioButton3_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(3, 3, 2);
        }

        private void crewFemaleRadioButton3_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(3, 3, 2);
        }

        private void crewProfessionBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(2);
        }

        private void crewLevelBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(2);
        }

        private void jettisonCrewMember3_Click(object sender, EventArgs e)
        {
            crewViewerIndex = 2;
            bool punct = false;
            if (jettisonCrewMember3.Text == "Hire!")
            {
                if ((crewProfessionBox3.SelectedIndex == -1) || (crewLevelBox3.SelectedIndex == -1) || (normalCrewComboxBox3.SelectedIndex == -1))
                {
                    MessageBox.Show("You need to fill in the crew details before hiring - please make sure you've entered the race, profession and level of your crew member", "Incomplete Crew Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (activeCrewCount < availableCrewSeats)
                    {
                        activeCrewCount++;

                        // Crew Active?
                        // { active (Y/N), leg, name, cost, effect1, effect2};
                        activeCrew[2, 0] = "Y";
                        activeCrew[2, 1] = "norm";
                        activeCrew[2, 2] = crewNameTextBox3.Text;
                        activeCrew[2, 3] = dailyCosttextBox3.Text;
                        activeCrew[2, 4] = crewEffect1Label3.Text;
                        activeCrew[2, 6] = crewProfessionBox3.Text;
                        activeCrew[2, 7] = crewLevelBox3.Text;
                        jettisonCrewMember3.Text = "Jettison";
                        jettisonCrewMember3.Image = Tame.Properties.Resources.cancel_48;

                        if (dailyCosttextBox3.Text != "")
                        {
                            try
                            {
                                string dailyCost = "0";
                                if (dailyCosttextBox3.Text.Contains(","))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox3.Text, ",", "");
                                    punct = true;
                                }
                                else if (dailyCosttextBox3.Text.Contains("."))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox3.Text, ".", "");
                                    punct = true;
                                }
                                else if (punct == false)
                                {
                                    dailyCost = dailyCosttextBox3.Text;
                                }
                                int dailyCostInt = int.Parse(dailyCost);

                                crewStatsLabel3.Text = string.Format("Monthly Cost: {1}{0}Yearly Cost: {2}{0}Cost After Death (est): {3}{0}", Environment.NewLine, (dailyCostInt * 30).ToString("N0"), (dailyCostInt * 365).ToString("N0"), (myMaths.Round(((double)dailyCostInt * 1.5), -3)).ToString("N0"));
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("The daily cost could not be turned into a number properly. Please make sure you've not got any letters or punctuation in the \"Daily Cost\" box.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        crewProfessionBox3.Enabled = false;
                        crewLevelBox3.Enabled = false;
                        crewNameTextBox3.Enabled = false;
                        crewInitialCostTextBox3.Enabled = false;
                        dailyCosttextBox3.Enabled = false;
                        normalCrewComboxBox3.Enabled = false;
                        crewMaleRadioButton3.Enabled = false;
                        crewFemaleRadioButton3.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("You can't hire this crew member. Your ship doesn't have enough crew seats left. Jettison another crew member, or select another ship to hire more crew", "Not Enough Crew Seats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (jettisonCrewMember3.Text == "Jettison")
            {
                string gender = "";
                if (crewMaleRadioButton3.Checked == true)
                {
                    gender = "him";
                }
                if (crewFemaleRadioButton3.Checked == true)
                {
                    gender = "her";
                }
                DialogResult jettisonDialogResult = MessageBox.Show(string.Format("\"Oh please God no, not the airlock! You can pay me later, pay me later!\" {0}{0}Are you really going to throw {1} out of the airlock? (Only hired members will affect your skills)", Environment.NewLine, gender), "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (jettisonDialogResult == DialogResult.Yes)
                {
                    activeCrewCount--;
                    activeCrew[2, 0] = "N";
                    jettisonCrewMember3.Text = "Hire!";
                    jettisonCrewMember3.Image = Tame.Properties.Resources.add_48;
                    crewStatsLabel3.Text = "";
                    crewProfessionBox3.Enabled = true;
                    crewLevelBox3.Enabled = true;
                    crewNameTextBox3.Enabled = true;
                    crewInitialCostTextBox3.Enabled = true;
                    dailyCosttextBox3.Enabled = true;
                    normalCrewComboxBox3.Enabled = true;
                    crewMaleRadioButton3.Enabled = true;
                    crewFemaleRadioButton3.Enabled = true;
                }
            }
            updateCrewImages(3, 3, 2);
            updateCrewViewer();

        }

        private void normalCrewComboxBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewImages(4, 4, 3);
        }

        private void crewMaleRadioButton4_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(4, 4, 3);
        }

        private void crewFemaleRadioButton4_CheckedChanged(object sender, EventArgs e)
        {
            updateCrewImages(4, 4, 3);
        }

        private void crewProfessionBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(3);
        }

        private void crewLevelBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            updateCrewEffect(3);
        }

        private void jettisonCrewMember4_Click(object sender, EventArgs e)
        {
            crewViewerIndex = 3;
            bool punct = false;
            if (jettisonCrewMember4.Text == "Hire!")
            {
                if ((crewProfessionBox4.SelectedIndex == -1) || (crewLevelBox4.SelectedIndex == -1) || (normalCrewComboxBox4.SelectedIndex == -1))
                {
                    MessageBox.Show("You need to fill in the crew details before hiring - please make sure you've entered the race, profession and level of your crew member", "Incomplete Crew Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (activeCrewCount < availableCrewSeats)
                    {
                        activeCrewCount++;
                        // Crew Active?
                        // { active (Y/N), leg, name, cost, effect1, effect2};

                        activeCrew[3, 0] = "Y";
                        activeCrew[3, 1] = "norm";
                        activeCrew[3, 2] = crewNameTextBox4.Text;
                        activeCrew[3, 3] = dailyCosttextBox4.Text;
                        activeCrew[3, 4] = crewEffect1Label4.Text;
                        activeCrew[3, 6] = crewProfessionBox4.Text;
                        activeCrew[3, 7] = crewLevelBox4.Text;
                        jettisonCrewMember4.Text = "Jettison";
                        jettisonCrewMember4.Image = Tame.Properties.Resources.cancel_48;

                        if (dailyCosttextBox4.Text != "")
                        {
                            try
                            {
                                string dailyCost = "0";
                                if (dailyCosttextBox4.Text.Contains(","))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox4.Text, ",", "");
                                    punct = true;
                                }
                                else if (dailyCosttextBox4.Text.Contains("."))
                                {
                                    dailyCost = Regex.Replace(dailyCosttextBox4.Text, ".", "");
                                    punct = true;
                                }
                                else if (punct == false)
                                {
                                    dailyCost = dailyCosttextBox4.Text;
                                }
                                int dailyCostInt = int.Parse(dailyCost);

                                crewStatsLabel4.Text = string.Format("Monthly Cost: {1}{0}Yearly Cost: {2}{0}Cost After Death (est): {3}{0}", Environment.NewLine, (dailyCostInt * 30).ToString("N0"), (dailyCostInt * 365).ToString("N0"), (myMaths.Round(((double)dailyCostInt * 1.5), -3)).ToString("N0"));
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("The daily cost could not be turned into a number properly. Please make sure you've not got any letters or punctuation in the \"Daily Cost\" box.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        crewProfessionBox4.Enabled = false;
                        crewLevelBox4.Enabled = false;
                        crewNameTextBox4.Enabled = false;
                        crewInitialCostTextBox4.Enabled = false;
                        dailyCosttextBox4.Enabled = false; 
                        normalCrewComboxBox4.Enabled = false;
                        crewMaleRadioButton4.Enabled = false;
                        crewFemaleRadioButton4.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("You can't hire this crew member. Your ship doesn't have enough crew seats left. Jettison another crew member, or select another ship to hire more crew", "Not Enough Crew Seats", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (jettisonCrewMember4.Text == "Jettison")
            {
                string gender = "";
                if (crewMaleRadioButton4.Checked == true)
                {
                    gender = "him";
                }
                if (crewFemaleRadioButton4.Checked == true)
                {
                    gender = "her";
                }
                DialogResult jettisonDialogResult = MessageBox.Show(string.Format("\"Oh please God no, not the airlock! You can pay me later, pay me later!\" {0}{0}Are you really going to throw {1} out of the airlock? (Only hired members will affect your skills)", Environment.NewLine, gender), "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (jettisonDialogResult == DialogResult.Yes)
                {
                    activeCrewCount--;
                    activeCrew[3, 0] = "N";
                    jettisonCrewMember4.Text = "Hire!";
                    jettisonCrewMember4.Image = Tame.Properties.Resources.add_48;

                    crewProfessionBox4.Enabled = true;
                    crewLevelBox4.Enabled = true;
                    crewNameTextBox4.Enabled = true;
                    crewInitialCostTextBox4.Enabled = true;
                    dailyCosttextBox4.Enabled = true;
                    normalCrewComboxBox4.Enabled = true;
                    crewMaleRadioButton4.Enabled = true;
                    crewFemaleRadioButton4.Enabled = true;
                    crewStatsLabel4.Text = "";
                }
            }
            updateCrewImages(4, 4, 3);
            updateCrewViewer();
        }

        private void updateCrewButtons()
        {
            // Enable Crew Entry forms (might be disabled if crew is hired when new ship is selected
            crewStatsLabel1.Text = "";
            legendaryComboBox.Enabled = true;
            crewProfessionBox1.Enabled = true;
            crewLevelBox1.Enabled = true;
            crewNameSubtitleTextBox.Enabled = true;
            crewInitialCostTextBox1.Enabled = true;
            dailyCosttextBox1.Enabled = true;
            normalCrewComboxBox1.Enabled = true;
            crewMaleRadioButton1.Enabled = true;
            crewFemaleRadioButton1.Enabled = true;

            crewStatsLabel2.Text = "";
            crewProfessionBox2.Enabled = true;
            crewLevelBox2.Enabled = true;
            crewNameTextBox2.Enabled = true;
            crewInitialCostTextBox2.Enabled = true;
            dailyCosttextBox2.Enabled = true;
            normalCrewComboxBox2.Enabled = true;
            crewMaleRadioButton2.Enabled = true;
            crewFemaleRadioButton2.Enabled = true;

            crewStatsLabel3.Text = "";
            crewProfessionBox3.Enabled = true;
            crewLevelBox3.Enabled = true;
            crewNameTextBox3.Enabled = true;
            crewInitialCostTextBox3.Enabled = true;
            dailyCosttextBox3.Enabled = true;
            normalCrewComboxBox3.Enabled = true;
            crewMaleRadioButton3.Enabled = true;
            crewFemaleRadioButton3.Enabled = true;

            crewProfessionBox4.Enabled = true;
            crewLevelBox4.Enabled = true;
            crewNameTextBox4.Enabled = true;
            crewInitialCostTextBox4.Enabled = true;
            dailyCosttextBox4.Enabled = true;
            normalCrewComboxBox4.Enabled = true;
            crewMaleRadioButton4.Enabled = true;
            crewFemaleRadioButton4.Enabled = true;
            crewStatsLabel4.Text = "";           

            if (availableCrewSeats == 0)
            {
                activeCrewCount = 0;
                jettisonCrewMember1.Enabled = false;
                jettisonCrewMember2.Enabled = false;
                jettisonCrewMember3.Enabled = false;
                jettisonCrewMember4.Enabled = false;

                jettisonCrewMember1.Text = "Hire!";
                jettisonCrewMember1.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember2.Text = "Hire!";
                jettisonCrewMember2.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember3.Text = "Hire!";
                jettisonCrewMember3.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember4.Text = "Hire!";
                jettisonCrewMember4.Image = Tame.Properties.Resources.add_48;
                activeCrew[0, 0] = "N"; activeCrew[1, 0] = "N"; activeCrew[2, 0] = "N"; activeCrew[3, 0] = "N";

                crewPanel1.Visible = false;
                crewPanel2.Visible = false;
                crewPanel3.Visible = false;
                crewPanel4.Visible = false;
            }
            if (availableCrewSeats == 1)
            {
                if (activeCrewCount > 1)
                {
                    activeCrewCount = 1;
                }
                jettisonCrewMember1.Enabled = true;
                jettisonCrewMember2.Enabled = false;
                jettisonCrewMember3.Enabled = false;
                jettisonCrewMember4.Enabled = false;

                jettisonCrewMember2.Text = "Hire!";
                jettisonCrewMember2.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember3.Text = "Hire!";
                jettisonCrewMember3.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember4.Text = "Hire!";
                jettisonCrewMember4.Image = Tame.Properties.Resources.add_48;

                activeCrew[1, 0] = "N"; activeCrew[2, 0] = "N"; activeCrew[3, 0] = "N";

                crewPanel1.Visible = true;
                crewPanel2.Visible = false;
                crewPanel3.Visible = false;
                crewPanel4.Visible = false;
            }
            if (availableCrewSeats == 2)
            {
                if (activeCrewCount > 2)
                {
                    activeCrewCount = 2;
                }
                jettisonCrewMember1.Enabled = true;
                jettisonCrewMember2.Enabled = true;
                jettisonCrewMember3.Enabled = false;
                jettisonCrewMember4.Enabled = false;

                jettisonCrewMember3.Text = "Hire!";
                jettisonCrewMember3.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember4.Text = "Hire!";
                jettisonCrewMember4.Image = Tame.Properties.Resources.add_48;
                activeCrew[2, 0] = "N"; activeCrew[3, 0] = "N";

                crewPanel1.Visible = true;
                crewPanel2.Visible = true;
                crewPanel3.Visible = false;
                crewPanel4.Visible = false;
            }
            if (availableCrewSeats == 3)
            {
                if (activeCrewCount > 3)
                {
                    activeCrewCount = 3;
                }
                jettisonCrewMember1.Enabled = true;
                jettisonCrewMember2.Enabled = true;
                jettisonCrewMember3.Enabled = true;
                jettisonCrewMember4.Enabled = false;

                jettisonCrewMember4.Image = Tame.Properties.Resources.add_48;
                jettisonCrewMember4.Text = "Hire!";
                activeCrew[3, 0] = "N";

                crewPanel1.Visible = true;
                crewPanel2.Visible = true;
                crewPanel3.Visible = true;
                crewPanel4.Visible = false;
            }
            if (availableCrewSeats == 4)
            {
                jettisonCrewMember1.Enabled = true;
                jettisonCrewMember2.Enabled = true;
                jettisonCrewMember3.Enabled = true;
                jettisonCrewMember4.Enabled = true;

                crewPanel1.Visible = true;
                crewPanel2.Visible = true;
                crewPanel3.Visible = true;
                crewPanel4.Visible = true;
            }
            if (useLegendaryCrewMemberCheckBox.Checked == true)
            {
                updateCrewImages(1, 0, 0);
            }
            else
            {
                updateCrewImages(1, 1, 0);
            }
            updateCrewImages(2, 2, 1);
            updateCrewImages(3, 3, 2);
            updateCrewImages(4, 4, 3);
           updateCrewViewer();
           determineMovementCost();
        }

        private void copyCrewToClipboardButton_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                Clipboard.SetDataObject(crewImportExportTextBox.Text, true);
            }
            catch (Exception)
            {
                error = true;
                MessageBox.Show("Copying to clipboard failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!error)
            {
                MessageBox.Show("Successfully copied Crew Code to clipboard", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void exportCrewButton_Click(object sender, EventArgs e)
        {
            // fscVersion == 4.2;
            // FSCv4.2 | CrewType : Gender : Name : Profession : Level : Cost : DailyCost | CrewType : Name :|||
            string exportString = "";

            if (useLegendaryCrewMemberCheckBox.Checked == true)
            {
                exportString = fscVersion + "|l:" + legendaryComboBox.Text + "|";
            }
            else
            {
                exportString = fscVersion + "|n:";

                if (crewMaleRadioButton1.Checked == true)
                {
                    exportString += "m:";
                }
                else
                {
                    exportString += "f:";
                }
                exportString += normalCrewComboxBox1.Text + ":" + crewNameSubtitleTextBox.Text + ":" + crewProfessionBox1.Text + ":" + crewLevelBox1.Text + ":" + crewInitialCostTextBox1.Text + ":" + dailyCosttextBox1.Text + "|";
            }
            // Box 2:
            exportString += "n:";
            if (crewMaleRadioButton2.Checked == true)
            {
                exportString += "m:";
            }
            else
            {
                exportString += "f:";
            }
            exportString += normalCrewComboxBox2.Text + ":" + crewNameTextBox2.Text + ":" + crewProfessionBox2.Text + ":" + crewLevelBox2.Text + ":" + crewInitialCostTextBox2.Text + ":" + dailyCosttextBox2.Text + "|";
            // Box 3:
            exportString += "n:";
            if (crewMaleRadioButton3.Checked == true)
            {
                exportString += "m:";
            }
            else
            {
                exportString += "f:";
            }
            exportString += normalCrewComboxBox3.Text + ":" + crewNameTextBox3.Text + ":" + crewProfessionBox3.Text + ":" + crewLevelBox3.Text + ":" + crewInitialCostTextBox3.Text + ":" + dailyCosttextBox3.Text + "|";
            // Box 3:
            exportString += "n:";
            if (crewMaleRadioButton4.Checked == true)
            {
                exportString += "m:";
            }
            else
            {
                exportString += "f:";
            }
            exportString += normalCrewComboxBox4.Text + ":" + crewNameTextBox4.Text + ":" + crewProfessionBox4.Text + ":" + crewLevelBox4.Text + ":" + crewInitialCostTextBox4.Text + ":" + dailyCosttextBox4.Text + "|";
            // Need boxes 2,3,4 here too.

            crewImportExportTextBox.Text = exportString;


        }

        private void importCrewButton_Click(object sender, EventArgs e)
        {
            
            DialogResult importDialogResult = MessageBox.Show("Importing Crew Code: Doing this will overwrite any Crew currently in the designer, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (importDialogResult == DialogResult.Yes)
            {
                string bigSeparator = "|";
                string littleSeparator = ":";
                int i;
                string crewImportString = "";
                for (i = 0; i < crewImportExportTextBox.Lines.Length; i++)
                {
                    crewImportString += crewImportExportTextBox.Lines[i];
                }
                string[] import;
                string[] crewMember;
                bool inputError = false;

                
                try
                {
                    // Split into larger chunks
                    import = crewImportString.Split(bigSeparator.ToCharArray());
                    if (crewImportExportTextBox.Text == "")
                    {
                        inputError = true;
                        MessageBox.Show("Error, can't import nothing." + Environment.NewLine + " Please put something in the text box.", "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if ((import[0] != fscVersion) && (!inputError))
                    {
                        MessageBox.Show(string.Format("Error, either you're attempting to import from an incompatible FSC version. (Only version \"{0}\" is supported). Or You have not entered a valid FSC string.", fscVersion), "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        inputError = true;
                    }
                    if (!inputError)
                    {
                        crewMember = import[1].Split(littleSeparator.ToCharArray());

                        // FSCv4.2 | CrewType : Gender :race : Name : Profession : Level : Cost : DailyCost | CrewType : Name :|||
                        if (crewMember[0] == "n")
                        {
                            useLegendaryCrewMemberCheckBox.Checked = false;
                            if (crewMember[1] == "m")
                            {
                                crewMaleRadioButton1.Checked = true;
                            }
                            else
                            {
                                crewFemaleRadioButton1.Checked = true;
                            }
                            normalCrewComboxBox1.Text = crewMember[2];
                            crewNameSubtitleTextBox.Text = crewMember[3];
                            crewProfessionBox1.Text = crewMember[4];
                            crewLevelBox1.Text = crewMember[5];
                            crewInitialCostTextBox1.Text = crewMember[6];
                            dailyCosttextBox1.Text = crewMember[7];
                        }
                        else
                        {
                            // dealing with legendary
                            useLegendaryCrewMemberCheckBox.Checked = true;
                            legendaryComboBox.Text = crewMember[1];     
                        }

                        // Crew Member 2
                        crewMember = import[2].Split(littleSeparator.ToCharArray());
                        if (crewMember[1] == "m")
                        {
                            crewMaleRadioButton2.Checked = true;
                        }
                        else
                        {
                            crewFemaleRadioButton2.Checked = true;
                        }
                        normalCrewComboxBox2.Text = crewMember[2];
                        crewNameTextBox2.Text = crewMember[3];
                        crewProfessionBox2.Text = crewMember[4];
                        crewLevelBox2.Text = crewMember[5];
                        crewInitialCostTextBox2.Text = crewMember[6];
                        dailyCosttextBox2.Text = crewMember[7];

                        // Crew Member 3
                        crewMember = import[3].Split(littleSeparator.ToCharArray());
                        if (crewMember[1] == "m")
                        {
                            crewMaleRadioButton3.Checked = true;
                        }
                        else
                        {
                            crewFemaleRadioButton3.Checked = true;
                        }
                        normalCrewComboxBox3.Text = crewMember[2];
                        crewNameTextBox3.Text = crewMember[3];
                        crewProfessionBox3.Text = crewMember[4];
                        crewLevelBox3.Text = crewMember[5];
                        crewInitialCostTextBox3.Text = crewMember[6];
                        dailyCosttextBox3.Text = crewMember[7];

                        // Crew Member 4
                        crewMember = import[4].Split(littleSeparator.ToCharArray());
                        if (crewMember[1] == "m")
                        {
                            crewMaleRadioButton4.Checked = true;
                        }
                        else
                        {
                            crewFemaleRadioButton4.Checked = true;
                        }
                        normalCrewComboxBox4.Text = crewMember[2];
                        crewNameTextBox4.Text = crewMember[3];
                        crewProfessionBox4.Text = crewMember[4];
                        crewLevelBox4.Text = crewMember[5];
                        crewInitialCostTextBox4.Text = crewMember[6];
                        dailyCosttextBox4.Text = crewMember[7];

                    }
                    else
                    {
                        MessageBox.Show("Error, something went wrong. Please make sure you're trying to use a valid Import String", "Input Error Detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                        
                }
                catch (Exception)
                {
                    MessageBox.Show("Oops, something went wrong with the import. Try removing all the text from the box and pasting in the FSC string again, and make sure you copied ALL the text from FSC.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }

        private void crewImportExportTextBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (crewImportExportTextBox.Text == "Paste Crew code to import here!")
            {
#if MONO // Fix for MONO bug: https://bugzilla.novell.com/show_bug.cgi?id=621475
                ieTextBox.SelectionStart = 0;
#endif
                crewImportExportTextBox.Text = "";
            }
        }

        private void clearCrewImportExportTextBoxButton_Click(object sender, EventArgs e)
        {
#if MONO // Fix for MONO bug: https://bugzilla.novell.com/show_bug.cgi?id=621475
                ieTextBox.SelectionStart = 0;
#endif
            crewImportExportTextBox.Text = "";
        }

        private void saveCrewButton_Click(object sender, EventArgs e)
        {
            DialogResult crewDialogResult = MessageBox.Show("Saving Crew: Doing this will overwrite the previously saved Crew, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (crewDialogResult == DialogResult.Yes)
            {
                unsavedChanges = false;
                if (Directory.Exists(tameDirectory) != true)
                {
                    Directory.CreateDirectory(tameDirectory);
                }
                // FSCv4.2 | CrewType : Gender :race : Name : Profession : Level : Cost : DailyCost | CrewType : Name :|||
                XmlTextWriter saveCrew = new XmlTextWriter(crewFile, null);
                saveCrew.WriteStartDocument();
                saveCrew.WriteComment("Tame Ship Calc: Auto-Generated XML File. This file holds the user's crew data settings from the \"crew\" tab");
                saveCrew.WriteStartElement("Root");

                saveCrew.WriteStartElement("crew1");
                saveCrew.WriteStartAttribute("crewType");
                if (useLegendaryCrewMemberCheckBox.Checked == true)
                {
                saveCrew.WriteString("leg");
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("name");
                saveCrew.WriteString(legendaryComboBox.Text);
                saveCrew.WriteEndAttribute();
                }
                else
                {
                    saveCrew.WriteString("norm");
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("gender");
                    if (crewMaleRadioButton1.Checked == true)
                    {
                        saveCrew.WriteString("m");
                    }
                    else
                    {
                        saveCrew.WriteString("f");
                    }
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("race");
                    saveCrew.WriteString(normalCrewComboxBox1.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("name");
                    saveCrew.WriteString(crewNameSubtitleTextBox.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("profession");
                    saveCrew.WriteString(crewProfessionBox1.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("level");
                    saveCrew.WriteString(crewLevelBox1.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("cost");
                    saveCrew.WriteString(crewInitialCostTextBox1.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("daily");
                    saveCrew.WriteString(dailyCosttextBox1.Text);
                    saveCrew.WriteEndAttribute();
                }
                saveCrew.WriteEndElement(); // close up "1"

                saveCrew.WriteStartElement("crew2");
                saveCrew.WriteStartAttribute("crewType");
                saveCrew.WriteString("norm");
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("gender");
                    if (crewMaleRadioButton2.Checked == true)
                    {
                        saveCrew.WriteString("m");
                    }
                    else
                    {
                        saveCrew.WriteString("f");
                    }
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("race");
                    saveCrew.WriteString(normalCrewComboxBox2.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("name");
                    saveCrew.WriteString(crewNameTextBox2.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("profession");
                    saveCrew.WriteString(crewProfessionBox2.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("level");
                    saveCrew.WriteString(crewLevelBox2.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("cost");
                    saveCrew.WriteString(crewInitialCostTextBox2.Text);
                    saveCrew.WriteEndAttribute();
                    saveCrew.WriteStartAttribute("daily");
                    saveCrew.WriteString(dailyCosttextBox2.Text);
                    saveCrew.WriteEndAttribute();                
                saveCrew.WriteEndElement(); // close up "2"

                saveCrew.WriteStartElement("crew3");
                saveCrew.WriteStartAttribute("crewType");
                saveCrew.WriteString("norm");
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("gender");
                if (crewMaleRadioButton3.Checked == true)
                {
                    saveCrew.WriteString("m");
                }
                else
                {
                    saveCrew.WriteString("f");
                }
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("race");
                saveCrew.WriteString(normalCrewComboxBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("name");
                saveCrew.WriteString(crewNameTextBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("profession");
                saveCrew.WriteString(crewProfessionBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("level");
                saveCrew.WriteString(crewLevelBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("cost");
                saveCrew.WriteString(crewInitialCostTextBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("daily");
                saveCrew.WriteString(dailyCosttextBox3.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteEndElement(); // close up "3"

                saveCrew.WriteStartElement("crew4");
                saveCrew.WriteStartAttribute("crewType");
                saveCrew.WriteString("norm");
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("gender");
                if (crewMaleRadioButton4.Checked == true)
                {
                    saveCrew.WriteString("m");
                }
                else
                {
                    saveCrew.WriteString("f");
                }
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("race");
                saveCrew.WriteString(normalCrewComboxBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("name");
                saveCrew.WriteString(crewNameTextBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("profession");
                saveCrew.WriteString(crewProfessionBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("level");
                saveCrew.WriteString(crewLevelBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("cost");
                saveCrew.WriteString(crewInitialCostTextBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteStartAttribute("daily");
                saveCrew.WriteString(dailyCosttextBox4.Text);
                saveCrew.WriteEndAttribute();
                saveCrew.WriteEndElement(); // close up "4"
                
                saveCrew.WriteEndElement(); // close up root.
                saveCrew.WriteEndDocument();
                saveCrew.Close();
            }
            updateUsedDiskSpace();
        
        }

        private void deleteCrewButton_Click(object sender, EventArgs e)
        {
            DialogResult deleteCrewDialogResult = MessageBox.Show("Deleting Saved Crew: Doing this will permanently delete any previously saved crew, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deleteCrewDialogResult == DialogResult.Yes)
            {
                if (Directory.Exists(tameDirectory))
                {
                    if (File.Exists(crewFile))
                    {
                        File.Delete(crewFile);
                    }
                }
                updateUsedDiskSpace();
            }
        }

        private void loadCrewButton_Click(object sender, EventArgs e)
        {
            if (startup == true)
            {
                loadCrewFromXML();
            }
            else
            {
                DialogResult crewDialogResult = MessageBox.Show("Loading Crew: Doing this will overwrite the crew you have right now, are you sure you wish to continue?", "Confirm Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (crewDialogResult == DialogResult.Yes)
                {
                    loadCrewFromXML();
                }
            }
        }

        private void loadCrewFromXML()
        {
            if (Directory.Exists(tameDirectory))
            {
                if (File.Exists(crewFile))
                {
                    XmlTextReader loadCrew = new XmlTextReader(crewFile);

                    // FSCv4.2 |CrewType (leg): Name | CrewType (normal) : Gender :race : Name : Profession : Level : Cost : DailyCost|||
                    while (loadCrew.Read())
                    {
                        if (loadCrew.NodeType == XmlNodeType.Element)
                        {
                            if (loadCrew.Name == "crew1")
                            {
                                if (loadCrew.GetAttribute(0) == "leg")
                                {
                                    useLegendaryCrewMemberCheckBox.Checked = true;
                                    legendaryComboBox.Text = loadCrew.GetAttribute(1);
                                }
                                else
                                {
                                    useLegendaryCrewMemberCheckBox.Checked = false;
                                    if (loadCrew.GetAttribute(1) == "m")
                                    {
                                        crewMaleRadioButton1.Checked = true;
                                    }
                                    else
                                    {
                                        crewFemaleRadioButton1.Checked = true;
                                    }
                                    normalCrewComboxBox1.Text = loadCrew.GetAttribute(2);
                                    crewNameSubtitleTextBox.Text = loadCrew.GetAttribute(3);
                                    crewProfessionBox1.Text = loadCrew.GetAttribute(4);
                                    crewLevelBox1.Text = loadCrew.GetAttribute(5);
                                    crewInitialCostTextBox1.Text = loadCrew.GetAttribute(6);
                                    dailyCosttextBox1.Text = loadCrew.GetAttribute(7);
                                }

                            }
                            if (loadCrew.Name == "crew2")
                            {
                                    if (loadCrew.GetAttribute(1) == "m")
                                    {
                                        crewMaleRadioButton2.Checked = true;
                                    }
                                    else
                                    {
                                        crewFemaleRadioButton2.Checked = true;
                                    }
                                    normalCrewComboxBox2.Text = loadCrew.GetAttribute(2);
                                    crewNameTextBox2.Text = loadCrew.GetAttribute(3);
                                    crewProfessionBox2.Text = loadCrew.GetAttribute(4);
                                    crewLevelBox2.Text = loadCrew.GetAttribute(5);
                                    crewInitialCostTextBox2.Text = loadCrew.GetAttribute(6);
                                    dailyCosttextBox2.Text = loadCrew.GetAttribute(7);
                                }

                            if (loadCrew.Name == "crew3")
                            {
                                    if (loadCrew.GetAttribute(1) == "m")
                                    {
                                        crewMaleRadioButton3.Checked = true;
                                    }
                                    else
                                    {
                                        crewFemaleRadioButton3.Checked = true;
                                    }
                                    normalCrewComboxBox3.Text = loadCrew.GetAttribute(2);
                                    crewNameTextBox3.Text = loadCrew.GetAttribute(3);
                                    crewProfessionBox3.Text = loadCrew.GetAttribute(4);
                                    crewLevelBox3.Text = loadCrew.GetAttribute(5);
                                    crewInitialCostTextBox3.Text = loadCrew.GetAttribute(6);
                                    dailyCosttextBox3.Text = loadCrew.GetAttribute(7);
                                }
                            if (loadCrew.Name == "crew4")
                            {
                                    if (loadCrew.GetAttribute(1) == "m")
                                    {
                                        crewMaleRadioButton4.Checked = true;
                                    }
                                    else
                                    {
                                        crewFemaleRadioButton4.Checked = true;
                                    }
                                    normalCrewComboxBox4.Text = loadCrew.GetAttribute(2);
                                    crewNameTextBox4.Text = loadCrew.GetAttribute(3);
                                    crewProfessionBox4.Text = loadCrew.GetAttribute(4);
                                    crewLevelBox4.Text = loadCrew.GetAttribute(5);
                                    crewInitialCostTextBox4.Text = loadCrew.GetAttribute(6);
                                    dailyCosttextBox4.Text = loadCrew.GetAttribute(7);
                                }

                            }
                        }
                    }
                 
                else
                {
                    if (startup != true)
                    {
                        MessageBox.Show(string.Format("{0} could not be found. Does a previous save file exist?", crewFile), "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

        }

        #endregion

        private void timer2_Tick(object sender, EventArgs e)
        {
            
            Process myProc = Process.GetCurrentProcess();
            memLabel.Text = "Memory Footprint: " + (myProc.PagedMemorySize64 / 1000000).ToString("N2") + "MB" + "/" + (myProc.PeakPagedMemorySize64 / 1000000).ToString("N2") + "MB" ;
        }

        private void showSLAATButton_Click(object sender, EventArgs e)
        {
            int modeArmorPoints = 4;
            int armorPoints = playerShip.GetShipData(ref modeArmorPoints, shipSelectBox.Text);
            GunArmorTesting slaatForm = new GunArmorTesting(armorPoints, GetImagePackPath(), gunLoadoutComboBox1.SelectedIndex, gunLoadoutComboBox2.SelectedIndex, gunLoadoutComboBox3.SelectedIndex, gunLoadoutComboBox4.SelectedIndex, gunLoadoutComboBox5.SelectedIndex);
            slaatForm.ShowDialog();
        }

        /// <summary>
        ///  Makes panes that we have not selected invisible and displays the one we want to see.
        /// </summary>
        /// <param name="paneToOpen"></param>
        private void updatePanes(UserControl paneToOpen)
        {
            paneToOpen.Visible = true;
            tabControl1.Visible = false;

            if ((aboutPane != null) && (aboutPane != paneToOpen))
            {
                aboutPane.Visible = false;
            }
            if ((designerPane != null) && (designerPane != paneToOpen))
            {
                designerPane.Visible = false;
            }
            if ((optionsPane != null) && (optionsPane != paneToOpen))
            {
                optionsPane.Visible = false;
            }
            if ((crewPane != null) && (crewPane != paneToOpen))
            {
                crewPane.Visible = false;
            }
        }
        /// <summary>
        /// Shows the "settings" pane if the mentu item is clicked.       
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (optionsPane == null)
            {
                optionsPane = new MainUI.OptionsPane();
                toolStripContainer1.ContentPanel.Controls.Add(optionsPane);
                //this.Controls.Add(optionsPane);
            }
    
             updatePanes(optionsPane);
                
           
        }

        private void aboutTameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (aboutPane == null)
            {
                aboutPane = new MainUI.AboutPane();                
                toolStripContainer1.ContentPanel.Controls.Add(aboutPane);
                //this.Controls.Add(optionsPane);
            }
            updatePanes(aboutPane);            
        }

        private void shipSelectBox_SelectedIndexChanged_1(object sender, EventArgs e)
        {

        }


        

}
}